ソースを参照

[init] Remove concept of "shutdown exit flags"

Remove the concept of shutdown exit flags, and replace it with a
counter used to keep track of exposed interfaces that require devices
to remain active.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13年前
コミット
962cada830

+ 3
- 3
src/arch/i386/drivers/net/undionly.c ファイルの表示

114
 /**
114
 /**
115
  * Prepare for exit
115
  * Prepare for exit
116
  *
116
  *
117
- * @v flags		Shutdown flags
117
+ * @v booting		System is shutting down for OS boot
118
  */
118
  */
119
-static void undionly_shutdown ( int flags ) {
119
+static void undionly_shutdown ( int booting ) {
120
 	/* If we are shutting down to boot an OS, clear the "keep PXE
120
 	/* If we are shutting down to boot an OS, clear the "keep PXE
121
 	 * stack" flag.
121
 	 * stack" flag.
122
 	 */
122
 	 */
123
-	if ( flags & SHUTDOWN_BOOT )
123
+	if ( booting )
124
 		preloaded_undi.flags &= ~UNDI_FL_KEEP_ALL;
124
 		preloaded_undi.flags &= ~UNDI_FL_KEEP_ALL;
125
 }
125
 }
126
 
126
 

+ 1
- 1
src/arch/i386/image/bzimage.c ファイルの表示

477
 	bzimage_update_header ( image, &bzimg, bzimg.rm_kernel );
477
 	bzimage_update_header ( image, &bzimg, bzimg.rm_kernel );
478
 
478
 
479
 	/* Prepare for exiting */
479
 	/* Prepare for exiting */
480
-	shutdown ( SHUTDOWN_BOOT );
480
+	shutdown_boot();
481
 
481
 
482
 	DBGC ( image, "bzImage %p jumping to RM kernel at %04x:0000 "
482
 	DBGC ( image, "bzImage %p jumping to RM kernel at %04x:0000 "
483
 	       "(stack %04x:%04zx)\n", image, ( bzimg.rm_kernel_seg + 0x20 ),
483
 	       "(stack %04x:%04zx)\n", image, ( bzimg.rm_kernel_seg + 0x20 ),

+ 1
- 1
src/arch/i386/image/elfboot.c ファイルの表示

48
 	/* An ELF image has no callback interface, so we need to shut
48
 	/* An ELF image has no callback interface, so we need to shut
49
 	 * down before invoking it.
49
 	 * down before invoking it.
50
 	 */
50
 	 */
51
-	shutdown ( SHUTDOWN_BOOT );
51
+	shutdown_boot();
52
 
52
 
53
 	/* Jump to OS with flat physical addressing */
53
 	/* Jump to OS with flat physical addressing */
54
 	DBGC ( image, "ELF %p starting execution at %lx\n", image, entry );
54
 	DBGC ( image, "ELF %p starting execution at %lx\n", image, entry );

+ 1
- 1
src/arch/i386/image/multiboot.c ファイルの表示

278
 	/* Multiboot images may not return and have no callback
278
 	/* Multiboot images may not return and have no callback
279
 	 * interface, so shut everything down prior to booting the OS.
279
 	 * interface, so shut everything down prior to booting the OS.
280
 	 */
280
 	 */
281
-	shutdown ( SHUTDOWN_BOOT );
281
+	shutdown_boot();
282
 
282
 
283
 	/* Build memory map after unhiding bootloader memory regions as part of
283
 	/* Build memory map after unhiding bootloader memory regions as part of
284
 	 * shutting everything down.
284
 	 * shutting everything down.

+ 1
- 1
src/arch/i386/image/nbi.c ファイルの表示

406
 	/* Shut down now if NBI image will not return */
406
 	/* Shut down now if NBI image will not return */
407
 	may_return = NBI_PROGRAM_RETURNS ( imgheader.flags );
407
 	may_return = NBI_PROGRAM_RETURNS ( imgheader.flags );
408
 	if ( ! may_return )
408
 	if ( ! may_return )
409
-		shutdown ( SHUTDOWN_BOOT );
409
+		shutdown_boot();
410
 
410
 
411
 	/* Execute NBI image */
411
 	/* Execute NBI image */
412
 	if ( NBI_LINEAR_EXEC_ADDR ( imgheader.flags ) ) {
412
 	if ( NBI_LINEAR_EXEC_ADDR ( imgheader.flags ) ) {

+ 6
- 2
src/arch/i386/interface/pcbios/int13.c ファイルの表示

1209
 	       int13->cylinders, int13->heads, int13->sectors_per_track );
1209
 	       int13->cylinders, int13->heads, int13->sectors_per_track );
1210
 
1210
 
1211
 	/* Hook INT 13 vector if not already hooked */
1211
 	/* Hook INT 13 vector if not already hooked */
1212
-	if ( list_empty ( &int13s ) )
1212
+	if ( list_empty ( &int13s ) ) {
1213
 		int13_hook_vector();
1213
 		int13_hook_vector();
1214
+		devices_get();
1215
+	}
1214
 
1216
 
1215
 	/* Add to list of emulated drives */
1217
 	/* Add to list of emulated drives */
1216
 	list_add ( &int13->list, &int13s );
1218
 	list_add ( &int13->list, &int13s );
1277
 	DBGC ( int13, "INT13 drive %02x unregistered\n", int13->drive );
1279
 	DBGC ( int13, "INT13 drive %02x unregistered\n", int13->drive );
1278
 
1280
 
1279
 	/* Unhook INT 13 vector if no more drives */
1281
 	/* Unhook INT 13 vector if no more drives */
1280
-	if ( list_empty ( &int13s ) )
1282
+	if ( list_empty ( &int13s ) ) {
1283
+		devices_put();
1281
 		int13_unhook_vector();
1284
 		int13_unhook_vector();
1285
+	}
1282
 
1286
 
1283
 	/* Drop list's reference to drive */
1287
 	/* Drop list's reference to drive */
1284
 	ref_put ( &int13->refcnt );
1288
 	ref_put ( &int13->refcnt );

+ 2
- 0
src/arch/i386/interface/pxe/pxe_call.c ファイルの表示

448
 	if ( ! int_1a_hooked ) {
448
 	if ( ! int_1a_hooked ) {
449
 		hook_bios_interrupt ( 0x1a, ( unsigned int ) pxe_int_1a,
449
 		hook_bios_interrupt ( 0x1a, ( unsigned int ) pxe_int_1a,
450
 				      &pxe_int_1a_vector );
450
 				      &pxe_int_1a_vector );
451
+		devices_get();
451
 		int_1a_hooked = 1;
452
 		int_1a_hooked = 1;
452
 	}
453
 	}
453
 
454
 
475
 			      strerror ( rc ) );
476
 			      strerror ( rc ) );
476
 			return rc;
477
 			return rc;
477
 		}
478
 		}
479
+		devices_put();
478
 		int_1a_hooked = 0;
480
 		int_1a_hooked = 0;
479
 	}
481
 	}
480
 
482
 

+ 1
- 1
src/arch/i386/interface/pxe/pxe_preboot.c ファイルの表示

290
 	pxe_deactivate();
290
 	pxe_deactivate();
291
 
291
 
292
 	/* Prepare for unload */
292
 	/* Prepare for unload */
293
-	shutdown ( SHUTDOWN_BOOT );
293
+	shutdown_boot();
294
 
294
 
295
 	/* Check to see if we still have any hooked interrupts */
295
 	/* Check to see if we still have any hooked interrupts */
296
 	if ( hooked_bios_interrupts != 0 ) {
296
 	if ( hooked_bios_interrupts != 0 ) {

+ 2
- 2
src/arch/i386/interface/syslinux/comboot_call.c ファイルの表示

531
 			break;
531
 			break;
532
 
532
 
533
 		/* Perform final cleanup */
533
 		/* Perform final cleanup */
534
-		shutdown ( SHUTDOWN_BOOT );
534
+		shutdown_boot();
535
 
535
 
536
 		/* Perform sequence of copies */
536
 		/* Perform sequence of copies */
537
 		shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx );
537
 		shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx );
608
 			break;
608
 			break;
609
 
609
 
610
 		/* Perform final cleanup */
610
 		/* Perform final cleanup */
611
-		shutdown ( SHUTDOWN_BOOT );
611
+		shutdown_boot();
612
 
612
 
613
 		/* Perform sequence of copies */
613
 		/* Perform sequence of copies */
614
 		shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx );
614
 		shuffle ( ix86->segs.es, ix86->regs.di, ix86->regs.cx );

+ 5
- 2
src/core/device.c ファイルの表示

35
 /** Registered root devices */
35
 /** Registered root devices */
36
 static LIST_HEAD ( devices );
36
 static LIST_HEAD ( devices );
37
 
37
 
38
+/** Device removal inhibition counter */
39
+int device_keep_count = 0;
40
+
38
 /**
41
 /**
39
  * Probe a root device
42
  * Probe a root device
40
  *
43
  *
87
  * Remove all devices
90
  * Remove all devices
88
  *
91
  *
89
  */
92
  */
90
-static void remove_devices ( int flags ) {
93
+static void remove_devices ( int booting __unused ) {
91
 	struct root_device *rootdev;
94
 	struct root_device *rootdev;
92
 	struct root_device *tmp;
95
 	struct root_device *tmp;
93
 
96
 
94
-	if ( flags & SHUTDOWN_KEEP_DEVICES ) {
97
+	if ( device_keep_count != 0 ) {
95
 		DBG ( "Refusing to remove devices on shutdown\n" );
98
 		DBG ( "Refusing to remove devices on shutdown\n" );
96
 		return;
99
 		return;
97
 	}
100
 	}

+ 1
- 1
src/core/main.c ファイルの表示

85
 			shell();
85
 			shell();
86
 	}
86
 	}
87
 
87
 
88
-	shutdown ( SHUTDOWN_EXIT | shutdown_exit_flags );
88
+	shutdown_exit();
89
 
89
 
90
 	return 0;
90
 	return 0;
91
 }
91
 }

+ 3
- 3
src/drivers/net/efi/snponly.c ファイルの表示

114
 /**
114
 /**
115
  * Prepare for exit
115
  * Prepare for exit
116
  *
116
  *
117
- * @v flags		Shutdown flags
117
+ * @v booting		System is shutting down for OS boot
118
  */
118
  */
119
-static void snponly_shutdown ( int flags ) {
119
+static void snponly_shutdown ( int booting ) {
120
 	/* If we are shutting down to boot an OS, make sure the SNP does not
120
 	/* If we are shutting down to boot an OS, make sure the SNP does not
121
 	 * stay active.
121
 	 * stay active.
122
 	 */
122
 	 */
123
-	if ( flags & SHUTDOWN_BOOT )
123
+	if ( booting )
124
 		snponly_dev.removal_state = EfiSimpleNetworkStopped;
124
 		snponly_dev.removal_state = EfiSimpleNetworkStopped;
125
 }
125
 }
126
 
126
 

+ 1
- 1
src/image/efi_image.c ファイルの表示

39
  */
39
  */
40
 static EFIAPI void efi_shutdown_hook ( EFI_EVENT event __unused,
40
 static EFIAPI void efi_shutdown_hook ( EFI_EVENT event __unused,
41
 				       void *context __unused ) {
41
 				       void *context __unused ) {
42
-	shutdown ( SHUTDOWN_BOOT );
42
+	shutdown_boot();
43
 }
43
 }
44
 
44
 
45
 /**
45
 /**

+ 18
- 0
src/include/ipxe/device.h ファイルの表示

112
 /** Declare a root device */
112
 /** Declare a root device */
113
 #define __root_device __table_entry ( ROOT_DEVICES, 01 )
113
 #define __root_device __table_entry ( ROOT_DEVICES, 01 )
114
 
114
 
115
+extern int device_keep_count;
116
+
117
+/**
118
+ * Prevent devices from being removed on shutdown
119
+ *
120
+ */
121
+static inline void devices_get ( void ) {
122
+	device_keep_count++;
123
+}
124
+
125
+/**
126
+ * Allow devices to be removed on shutdown
127
+ *
128
+ */
129
+static inline void devices_put ( void ) {
130
+	device_keep_count--;
131
+}
132
+
115
 extern struct device * identify_device ( struct interface *intf );
133
 extern struct device * identify_device ( struct interface *intf );
116
 #define identify_device_TYPE( object_type ) \
134
 #define identify_device_TYPE( object_type ) \
117
 	typeof ( struct device * ( object_type ) )
135
 	typeof ( struct device * ( object_type ) )

+ 18
- 12
src/include/ipxe/init.h ファイルの表示

32
 
32
 
33
 /** @} */
33
 /** @} */
34
 
34
 
35
-/** Shutdown flags */
36
-enum shutdown_flags {
37
-	/** Shutdown is in order to exit (return to iPXE's caller) */
38
-	SHUTDOWN_EXIT = 0x0001,
39
-	/** Shutdown is in order to boot an OS */
40
-	SHUTDOWN_BOOT = 0x0002,
41
-	/** Do not remove devices */
42
-	SHUTDOWN_KEEP_DEVICES = 0x0004,
43
-};
44
-
45
 /**
35
 /**
46
  * A startup/shutdown function
36
  * A startup/shutdown function
47
  *
37
  *
50
  */
40
  */
51
 struct startup_fn {
41
 struct startup_fn {
52
 	void ( * startup ) ( void );
42
 	void ( * startup ) ( void );
53
-	void ( * shutdown ) ( int flags );
43
+	void ( * shutdown ) ( int booting );
54
 };
44
 };
55
 
45
 
56
 /** Startup/shutdown function table */
46
 /** Startup/shutdown function table */
76
 
66
 
77
 extern void initialise ( void );
67
 extern void initialise ( void );
78
 extern void startup ( void );
68
 extern void startup ( void );
79
-extern void shutdown ( int flags );
69
+extern void shutdown ( int booting );
70
+
71
+/**
72
+ * Shut down system for OS boot
73
+ *
74
+ */
75
+static inline void shutdown_boot ( void ) {
76
+	shutdown ( 1 );
77
+}
78
+
79
+/**
80
+ * Shut down system for exit back to firmware
81
+ *
82
+ */
83
+static inline void shutdown_exit ( void ) {
84
+	shutdown ( 0 );
85
+}
80
 
86
 
81
 #endif /* _IPXE_INIT_H */
87
 #endif /* _IPXE_INIT_H */

+ 0
- 2
src/include/usr/autoboot.h ファイルの表示

12
 #include <ipxe/in.h>
12
 #include <ipxe/in.h>
13
 struct net_device;
13
 struct net_device;
14
 
14
 
15
-extern int shutdown_exit_flags;
16
-
17
 extern int netboot ( struct net_device *netdev );
15
 extern int netboot ( struct net_device *netdev );
18
 extern int autoboot ( void );
16
 extern int autoboot ( void );
19
 extern int boot_next_server_and_filename ( struct in_addr next_server,
17
 extern int boot_next_server_and_filename ( struct in_addr next_server,

+ 0
- 4
src/usr/autoboot.c ファイルの表示

40
  *
40
  *
41
  */
41
  */
42
 
42
 
43
-/** Shutdown flags for exit */
44
-int shutdown_exit_flags = 0;
45
-
46
 /**
43
 /**
47
  * Perform PXE menu boot when PXE stack is not available
44
  * Perform PXE menu boot when PXE stack is not available
48
  */
45
  */
193
 	if ( fetch_intz_setting ( NULL, &keep_san_setting ) != 0 ) {
190
 	if ( fetch_intz_setting ( NULL, &keep_san_setting ) != 0 ) {
194
 		printf ( "Preserving connection to SAN device %#02x\n",
191
 		printf ( "Preserving connection to SAN device %#02x\n",
195
 			 drive );
192
 			 drive );
196
-		shutdown_exit_flags |= SHUTDOWN_KEEP_DEVICES;
197
 		goto err_keep_san;
193
 		goto err_keep_san;
198
 	}
194
 	}
199
 
195
 

読み込み中…
キャンセル
保存