changeset 10525:c8fd4dff34d8

6879804 network boot can't do fastreboot to disk after install
author Konstantin Ananyev <Konstantin.Ananyev@Sun.COM>
date Mon, 14 Sep 2009 13:03:18 -0700
parents 80ac731fde86
children a1c57e83a4db
files usr/src/uts/common/sys/multiboot.h usr/src/uts/i86pc/os/fakebop.c usr/src/uts/i86pc/os/fastboot.c usr/src/uts/i86pc/sys/fastboot.h
diffstat 4 files changed, 78 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/sys/multiboot.h	Mon Sep 14 15:19:08 2009 -0400
+++ b/usr/src/uts/common/sys/multiboot.h	Mon Sep 14 13:03:18 2009 -0700
@@ -98,30 +98,62 @@
 } mb_memory_map_t;
 
 
+/* Drive Info structure.  */
+typedef struct mb_drive_info {
+	uint32_t	size;		/* The size of this structure */
+	uint8_t		drive_number;	/* The BIOS drive number */
+	uint8_t		drive_mode;	/* The access mode (see below) */
+	uint16_t	drive_cylinders;	/* The BIOS geometry */
+	uint8_t		drive_heads;
+	uint8_t		drive_sectors;
+	/* The array of I/O ports used for the drive.  */
+	uint16_t	drive_ports[1];
+} mb_drive_info_t;
+
+/* Drive Mode.  */
+#define	MB_DI_CHS_MODE		0
+#define	MB_DI_LBA_MODE		1
+
+
 /*
  * The Multiboot information. This is supplied by the multiboot loader
  * for the OS.
  *
  * The flag bit fields defined what multiboot info the boot
  * loader (see struct multiboot_info below) supplied:
- *	flag[0]		mem_upper, mem_loader
- *	flag[1]		boot_device
- *	flag[2]		cmdline (for launching kernel)
- *	flag[3]		mods_count, mods_addr
- *	flag[4]		symbol table for a.out
- *	flag[5]		symbol table for elf
- *	flag[6]		mmap_length, mmap_addr
- *	flag[7]		drives_length, drivers_addr
- *	flag[8]		config_table
- *	flag[9]		boot_loader_name
- *	flag[10]	apm_table
- *	flag[11]	vbe_control_info
- *			vbe_mode_info
- *			vbe_mode
- *			vbe_interface_seg
- *			vbe_interface_off
- *			vbe_interface_len
  */
+/* flag[0]	mem_upper, mem_loader */
+#define	MB_INFO_MEMORY			0x00000001
+/* flag[1]	boot_device */
+#define	MB_INFO_BOOTDEV			0x00000002
+/* flag[2]	cmdline (for launching kernel) */
+#define	MB_INFO_CMDLINE			0x00000004
+/* flag[3]	mods_count, mods_addr */
+#define	MB_INFO_MODS			0x00000008
+/* flag[4]	symbol table for a.out */
+#define	MB_INFO_AOUT_SYMS		0x00000010
+/* flag[5]	symbol table for elf */
+#define	MB_INFO_ELF_SHDR		0x00000020
+/* flag[6]	mmap_length, mmap_addr */
+#define	MB_INFO_MEM_MAP			0x00000040
+/* flag[7]	drives_length, drivers_addr */
+#define	MB_INFO_DRIVE_INFO		0x00000080
+/* flag[8]	config_table */
+#define	MB_INFO_CONFIG_TABLE		0x00000100
+/* flag[9]	boot_loader_name */
+#define	MB_INFO_BOOT_LOADER_NAME	0x00000200
+/* flag[10]	apm_table */
+#define	MB_INFO_APM_TABLE		0x00000400
+/*
+ * flag[11]	vbe_control_info
+ *		vbe_mode_info
+ *		vbe_mode
+ *		vbe_interface_seg
+ *		vbe_interface_off
+ *		vbe_interface_len
+ */
+#define	MB_INFO_VIDEO_INFO		0x00000800
+
 typedef struct multiboot_info {
 	uint32_t	flags;
 	uint32_t	mem_lower;	/* # of pages below 1Meg */
--- a/usr/src/uts/i86pc/os/fakebop.c	Mon Sep 14 15:19:08 2009 -0400
+++ b/usr/src/uts/i86pc/os/fakebop.c	Mon Sep 14 13:03:18 2009 -0700
@@ -139,7 +139,7 @@
  */
 multiboot_info_t saved_mbi;
 mb_memory_map_t saved_mmap[FASTBOOT_SAVED_MMAP_COUNT];
-struct sol_netinfo saved_drives[FASTBOOT_SAVED_DRIVES_COUNT];
+uint8_t saved_drives[FASTBOOT_SAVED_DRIVES_SIZE];
 char saved_cmdline[FASTBOOT_SAVED_CMDLINE_LEN];
 int saved_cmdline_len = 0;
 size_t saved_file_size[FASTBOOT_MAX_FILES_MAP];
@@ -1102,14 +1102,19 @@
 		    mbi->mmap_length);
 	}
 
-	if (mbi->drives_length > sizeof (saved_drives)) {
-		DBG(mbi->drives_length);
-		DBG_MSG("mbi->drives_length too big: clearing "
-		    "fastreboot_capable\n");
-		fastreboot_capable = 0;
+	if ((mbi->flags & MB_INFO_DRIVE_INFO) != 0) {
+		if (mbi->drives_length > sizeof (saved_drives)) {
+			DBG(mbi->drives_length);
+			DBG_MSG("mbi->drives_length too big: clearing "
+			    "fastreboot_capable\n");
+			fastreboot_capable = 0;
+		} else {
+			bcopy((void *)(uintptr_t)mbi->drives_addr,
+			    (void *)saved_drives, mbi->drives_length);
+		}
 	} else {
-		bcopy((void *)(uintptr_t)mbi->drives_addr, (void *)saved_drives,
-		    mbi->drives_length);
+		saved_mbi.drives_length = 0;
+		saved_mbi.drives_addr = NULL;
 	}
 
 	/*
@@ -1124,7 +1129,6 @@
 	    i < xbi->bi_module_cnt; i++, modp++) {
 		saved_file_size[FASTBOOT_NAME_BOOTARCHIVE] += modp->bm_size;
 	}
-
 }
 #endif	/* __xpv */
 
@@ -1383,7 +1387,7 @@
 	 */
 	save_boot_info(mbi, xbootp);
 
-	if (mbi != NULL && mbi->flags & 0x2) {
+	if (mbi != NULL && mbi->flags & MB_INFO_BOOTDEV) {
 		boot_device = mbi->boot_device >> 24;
 		if (boot_device == 0x20)
 			netboot++;
--- a/usr/src/uts/i86pc/os/fastboot.c	Mon Sep 14 15:19:08 2009 -0400
+++ b/usr/src/uts/i86pc/os/fastboot.c	Mon Sep 14 13:03:18 2009 -0700
@@ -189,7 +189,7 @@
  */
 extern multiboot_info_t saved_mbi;
 extern mb_memory_map_t saved_mmap[FASTBOOT_SAVED_MMAP_COUNT];
-extern struct sol_netinfo saved_drives[FASTBOOT_SAVED_DRIVES_COUNT];
+extern uint8_t saved_drives[FASTBOOT_SAVED_DRIVES_SIZE];
 extern char saved_cmdline[FASTBOOT_SAVED_CMDLINE_LEN];
 extern int saved_cmdline_len;
 extern size_t saved_file_size[];
@@ -558,6 +558,12 @@
 		    arglen);
 	}
 
+	/* clear fields and flags that are not copied */
+	bzero(&mbi->config_table,
+	    sizeof (*mbi) - offsetof(multiboot_info_t, config_table));
+	mbi->flags &= ~(MB_INFO_CONFIG_TABLE | MB_INFO_BOOT_LOADER_NAME |
+	    MB_INFO_APM_TABLE | MB_INFO_VIDEO_INFO);
+
 	return (0);
 }
 
--- a/usr/src/uts/i86pc/sys/fastboot.h	Mon Sep 14 15:19:08 2009 -0400
+++ b/usr/src/uts/i86pc/sys/fastboot.h	Mon Sep 14 13:03:18 2009 -0700
@@ -64,7 +64,14 @@
  * fast reboot.
  */
 #define	FASTBOOT_SAVED_MMAP_COUNT	32
-#define	FASTBOOT_SAVED_DRIVES_COUNT	9
+
+#define	FASTBOOT_SAVED_DRIVES_MAX	8
+#define	FASTBOOT_SAVED_DRIVES_PORT_MAX	128
+#define	FASTBOOT_SAVED_DRIVES_SIZE	\
+	((offsetof(struct mb_drive_info, drive_ports) +	\
+	FASTBOOT_SAVED_DRIVES_PORT_MAX * sizeof (uint16_t)) *	\
+	FASTBOOT_SAVED_DRIVES_MAX)
+
 #define	FASTBOOT_SAVED_CMDLINE_LEN	MMU_PAGESIZE