浏览代码

[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 年前
父节点
当前提交
e7ee2eda4b

+ 0
- 28
src/arch/x86/interface/pcbios/int13.c 查看文件

@@ -44,8 +44,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
44 44
 #include <ipxe/pci.h>
45 45
 #include <ipxe/iso9660.h>
46 46
 #include <ipxe/eltorito.h>
47
-#include <ipxe/dhcp.h>
48
-#include <ipxe/settings.h>
49 47
 #include <realmode.h>
50 48
 #include <bios.h>
51 49
 #include <biosint.h>
@@ -1992,32 +1990,6 @@ static int int13_describe ( unsigned int drive ) {
1992 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 1993
 PROVIDE_SANBOOT ( pcbios, san_hook, int13_hook );
2022 1994
 PROVIDE_SANBOOT ( pcbios, san_unhook, int13_unhook );
2023 1995
 PROVIDE_SANBOOT ( pcbios, san_boot, int13_boot );

+ 0
- 1
src/core/null_sanboot.c 查看文件

@@ -43,7 +43,6 @@ static int null_san_describe ( unsigned int drive __unused ) {
43 43
 	return -EOPNOTSUPP;
44 44
 }
45 45
 
46
-PROVIDE_SANBOOT_INLINE ( null, san_default_drive );
47 46
 PROVIDE_SANBOOT ( null, san_hook, null_san_hook );
48 47
 PROVIDE_SANBOOT ( null, san_unhook, null_san_unhook );
49 48
 PROVIDE_SANBOOT ( null, san_boot, null_san_boot );

+ 39
- 0
src/core/sanboot.c 查看文件

@@ -39,8 +39,20 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
39 39
 #include <ipxe/timer.h>
40 40
 #include <ipxe/process.h>
41 41
 #include <ipxe/iso9660.h>
42
+#include <ipxe/dhcp.h>
43
+#include <ipxe/settings.h>
42 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 57
  * Timeout for block device commands (in ticks)
46 58
  *
@@ -541,6 +553,7 @@ int register_sandev ( struct san_device *sandev ) {
541 553
 
542 554
 	/* Add to list of SAN devices */
543 555
 	list_add_tail ( &sandev->list, &san_devices );
556
+	DBGC ( sandev, "SAN %#02x registered\n", sandev->drive );
544 557
 
545 558
 	return 0;
546 559
 }
@@ -560,4 +573,30 @@ void unregister_sandev ( struct san_device *sandev ) {
560 573
 
561 574
 	/* Remove from list of SAN devices */
562 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 查看文件

@@ -15,13 +15,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15 15
 #define SANBOOT_PREFIX_efi __efi_
16 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 18
 #endif /* _IPXE_EFI_BLOCK_H */

+ 0
- 5
src/include/ipxe/null_sanboot.h 查看文件

@@ -15,9 +15,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
15 15
 #define SANBOOT_PREFIX_null __null_
16 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 18
 #endif /* _IPXE_NULL_SANBOOT_H */

+ 1
- 7
src/include/ipxe/sanboot.h 查看文件

@@ -95,13 +95,6 @@ struct san_device {
95 95
 /* Include all architecture-dependent sanboot API headers */
96 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 99
  * Hook SAN device
107 100
  *
@@ -212,5 +205,6 @@ extern int sandev_rw ( struct san_device *sandev, uint64_t lba,
212 205
 extern struct san_device * alloc_sandev ( struct uri *uri, size_t priv_size );
213 206
 extern int register_sandev ( struct san_device *sandev );
214 207
 extern void unregister_sandev ( struct san_device *sandev );
208
+extern unsigned int san_default_drive ( void );
215 209
 
216 210
 #endif /* _IPXE_SANBOOT_H */

+ 0
- 1
src/interface/efi/efi_block.c 查看文件

@@ -1055,7 +1055,6 @@ static int efi_block_boot ( unsigned int drive ) {
1055 1055
 	return rc;
1056 1056
 }
1057 1057
 
1058
-PROVIDE_SANBOOT_INLINE ( efi, san_default_drive );
1059 1058
 PROVIDE_SANBOOT ( efi, san_hook, efi_block_hook );
1060 1059
 PROVIDE_SANBOOT ( efi, san_unhook, efi_block_unhook );
1061 1060
 PROVIDE_SANBOOT ( efi, san_describe, efi_block_describe );

正在加载...
取消
保存