⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grub-0.93-diff

📁 从linux移植到dos下的grub
💻 93-DIFF
📖 第 1 页 / 共 4 页
字号:
   grub_printf (")"); +  rawread_ignore_memmove_overflow = 1;   /* Read in the whole file to DUMMY.  */   disk_read_hook = disk_read_blocklist_func;-  if (! grub_read (dummy, -1))-    goto fail;+  err = grub_read (dummy, -1);+  disk_read_hook = 0;+  rawread_ignore_memmove_overflow = 0;+  if (! err)+    goto fail_read;    /* The last entry may not be printed yet.  Don't check if it is a    * full sector, since it doesn't matter if we read too much. */   if (num_sectors > 0)-    grub_printf ("%s%d+%d", num_entries ? "," : "",+    {+      if (query_block_entries >= 0)+        grub_printf ("%s%d+%d", num_entries ? "," : "", 		 start_sector - part_start, num_sectors);+      num_entries++;+    } -  grub_printf ("\n");-  - fail:-  disk_read_hook = 0;+  if (query_block_entries >= 0)+    grub_printf ("\n");++  if (num_entries > 1)+    query_block_entries = num_entries;+  else+    {+      query_block_entries = 1;+      map_start_sector = start_sector;+      map_num_sectors = num_sectors;+    }++fail_read:   grub_close ();+fail_open:+  if (query_block_entries < 0)+    query_block_entries = 0;   return errnum; } @@ -266,19 +319,20 @@       /* Chainloader */              /* Check if we should set the int13 handler.  */-      if (bios_drive_map[0] != 0)+      if (! drive_map_slot_empty (bios_drive_map[0])) 	{ 	  int i; 	   	  /* Search for SAVED_DRIVE.  */ 	  for (i = 0; i < DRIVE_MAP_SIZE; i++) 	    {-	      if (! bios_drive_map[i])+	      if (drive_map_slot_empty (bios_drive_map[i])) 		break;-	      else if ((bios_drive_map[i] & 0xFF) == saved_drive)+	      else if ((bios_drive_map[i].drive_map & 0xFF) == saved_drive) 		{ 		  /* Exchage SAVED_DRIVE with the mapped drive.  */-		  saved_drive = (bios_drive_map[i] >> 8) & 0xFF;+		  if (! bios_drive_map[i].sector_count && ! bios_drive_map[i].start_sector)+		  saved_drive = (bios_drive_map[i].drive_map >> 8) & 0xFF; 		  break; 		} 	    }@@ -448,8 +502,9 @@   if (IS_PC_SLICE_TYPE_FAT (current_slice)       && ! grub_memcmp ((char *) BOOTSEC_LOCATION + BOOTSEC_BPB_SYSTEM_ID, 			"MSWIN", 5))-    *((unsigned long *) (BOOTSEC_LOCATION + BOOTSEC_BPB_HIDDEN_SECTORS))-      = part_start;+    if (*((unsigned long *) (BOOTSEC_LOCATION + BOOTSEC_BPB_HIDDEN_SECTORS)))+        *((unsigned long *) (BOOTSEC_LOCATION + BOOTSEC_BPB_HIDDEN_SECTORS))+          = part_start;    errnum = ERR_NONE;   @@ -2423,30 +2478,69 @@   char *from_drive;   unsigned long to, from;   int i;+  unsigned long start_sector, sector_count;+  char *filename;++  start_sector = sector_count = 0;+  int readonly = 0;++  if (grub_memcmp (arg, "--read-only", 11) == 0)+    {+      readonly = 1;+      arg = skip_to (0, arg);+    }      to_drive = arg;   from_drive = skip_to (0, arg); -  /* Get the drive number for TO_DRIVE.  */-  set_device (to_drive);-  if (errnum)-    return 1;-  to = current_drive;-   /* Get the drive number for FROM_DRIVE.  */   set_device (from_drive);   if (errnum)     return 1;   from = current_drive; +  /* Get the drive number for TO_DRIVE.  */+  filename = set_device (to_drive);+//if (filename)+//grub_printf ("TO-filename=%s\n",filename);+  if (errnum)+    return 1;+  to = current_drive;+//grub_printf ("TO-current_partition=%x\n",current_partition);++  if (current_partition == 0xFFFFFF && *filename == 0x20)+	goto map_whole_drive;++  query_block_entries = -1; /* query block list only */+  blocklist_func (to_drive, flags);+//grub_printf (", errnum=%d, query_block_entries=%d,map_start_sector=%d,map_num_sectors=%d,sizeof (struct drive_map_slot)=%d\n", errnum, query_block_entries, map_start_sector, map_num_sectors, sizeof (struct drive_map_slot));+  if (errnum == 0)+    {+      if (query_block_entries == 1)+	{+		start_sector = map_start_sector;+		sector_count = ((~map_num_sectors) & 0xfffffffe) | readonly;+	}+      else //if (query_block_entries > 1)+	{+		return errnum = ERR_NON_CONTIGUOUS;+	}+      //else+	//return errnum;+    }+  else+    return errnum;++map_whole_drive:+   /* Search for an empty slot in BIOS_DRIVE_MAP.  */   for (i = 0; i < DRIVE_MAP_SIZE; i++)     {       /* Perhaps the user wants to override the map.  */-      if ((bios_drive_map[i] & 0xff) == from)+      if ((bios_drive_map[i].drive_map & 0xff) == from) 	break;       -      if (! bios_drive_map[i])+      if (drive_map_slot_empty (bios_drive_map[i])) 	break;     } @@ -2459,9 +2553,15 @@   if (to == from)     /* If TO is equal to FROM, delete the entry.  */     grub_memmove ((char *) &bios_drive_map[i], (char *) &bios_drive_map[i + 1],-		  sizeof (unsigned short) * (DRIVE_MAP_SIZE - i));+		  sizeof (struct drive_map_slot) * (DRIVE_MAP_SIZE - i));   else-    bios_drive_map[i] = from | (to << 8);+    {+      bios_drive_map[i].drive_map = from | (to << 8);+      bios_drive_map[i].start_sector = (unsigned short)(start_sector & 0xffff);+      bios_drive_map[i].start_sector_hi = (unsigned short)(start_sector >> 16);+      bios_drive_map[i].sector_count = (unsigned short)(sector_count & 0xffff) | readonly;+      bios_drive_map[i].sector_count_hi = (unsigned short)(sector_count >> 16);+    }      return 0; }@@ -2471,10 +2571,13 @@   "map",   map_func,   BUILTIN_CMDLINE | BUILTIN_HELP_LIST,-  "map TO_DRIVE FROM_DRIVE",+  "map [--read-only] TO_DRIVE FROM_DRIVE",   "Map the drive FROM_DRIVE to the drive TO_DRIVE. This is necessary"   " when you chain-load some operating systems, such as DOS, if such an"-  " OS resides at a non-first drive."+  " OS resides at a non-first drive. TO_DRIVE can be a disk file, this"+  " indicates a disk emulation. If TO_DRIVE is a disk file, it must be"+  " contiguous(i.e., no holes in it). If --read-only is given, the"+  " emulated drive will be write-protected." };  diff -Naur grub-0.93/stage2/common.c grub-0.93_dos/stage2/common.c--- grub-0.93/stage2/common.c	2002-06-04 13:04:55.000000000 +0000+++ grub-0.93_dos/stage2/common.c	2003-09-23 14:50:13.000000000 +0000@@ -51,8 +51,7 @@ {   [ERR_NONE] = 0,   [ERR_BAD_ARGUMENT] = "Invalid argument",-  [ERR_BAD_FILENAME] =-  "Filename must be either an absolute pathname or blocklist",+  [ERR_BAD_FILENAME] = "Filename must be either an absolute pathname or blocklist",   [ERR_BAD_FILETYPE] = "Bad file or directory type",   [ERR_BAD_GZIP_DATA] = "Bad or corrupt data while decompressing file",   [ERR_BAD_GZIP_HEADER] = "Bad or incompatible header in compressed file",@@ -66,8 +65,7 @@   [ERR_DEV_NEED_INIT] = "Device not initialized yet",   [ERR_DEV_VALUES] = "Invalid device requested",   [ERR_EXEC_FORMAT] = "Invalid or unsupported executable format",-  [ERR_FILELENGTH] =-  "Filesystem compatibility error, cannot read whole file",+  [ERR_FILELENGTH] = "Filesystem compatibility error, cannot read whole file",   [ERR_FILE_NOT_FOUND] = "File not found",   [ERR_FSYS_CORRUPT] = "Inconsistent filesystem structure",   [ERR_FSYS_MOUNT] = "Cannot mount selected partition",@@ -77,6 +75,7 @@   [ERR_NO_DISK] = "Selected disk does not exist",   [ERR_NO_DISK_SPACE] = "No spare sectors on the disk",   [ERR_NO_PART] = "No such partition",+  [ERR_NON_CONTIGUOUS] = "File for drive emulation must be in one contiguous disk area",   [ERR_NUMBER_OVERFLOW] = "Overflow while parsing number",   [ERR_NUMBER_PARSING] = "Error while parsing number",   [ERR_OUTSIDE_PART] = "Attempt to access block outside partition",diff -Naur grub-0.93/stage2/disk_io.c grub-0.93_dos/stage2/disk_io.c--- grub-0.93/stage2/disk_io.c	2002-12-04 22:54:14.000000000 +0000+++ grub-0.93_dos/stage2/disk_io.c	2003-09-23 14:50:13.000000000 +0000@@ -117,6 +117,8 @@ int buf_track; struct geometry buf_geom; +int rawread_ignore_memmove_overflow = 0;/* blocklist_func() set this to 1 */+ /* filesystem common variables */ int filepos; int filemax;@@ -250,8 +252,13 @@ 	}        memmove (buf, (char *) bufaddr, size);--      buf += size;+      if (rawread_ignore_memmove_overflow && errnum == ERR_WONT_FIT)+	{+	  errnum = 0;+	  buf = NULL; /* so that further memcheck() always fail */+	}+      else+	buf += size;       byte_len -= size;       sector += num_sect;       slen -= num_sect;diff -Naur grub-0.93/stage2/dosstart.S grub-0.93_dos/stage2/dosstart.S--- grub-0.93/stage2/dosstart.S	1970-01-01 00:00:00.000000000 +0000+++ grub-0.93_dos/stage2/dosstart.S	2003-09-23 14:54:09.000000000 +0000@@ -0,0 +1,1053 @@+/*+ *  dosstart.S -- DOS EXE-header and startup code for GNU GRUB+ *  Copyright (C) 2003  Tinybit(tinybit@163.net)+ *+ *  This program is free software; you can redistribute it and/or modify+ *  it under the terms of the GNU General Public License as published by+ *  the Free Software Foundation; either version 2 of the License, or+ *  (at your option) any later version.+ *+ *  This program is distributed in the hope that it will be useful,+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+ *  GNU General Public License for more details.+ *+ *  You should have received a copy of the GNU General Public License+ *  along with this program; if not, write to the Free Software+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.+ */++/*+ * This program is used to generate the grub.exe file, which runs off DOS.+ *+ * Use the following shell command to generate the grub.exe file:+ *+ * 	cat dosstart pre_stage2 > grub.exe+ *+ */++#define ASM_FILE+#include <shared.h>+#include <stage2_size.h>+	+#define DOSSTART_SIZE 0x0e00 /* should be sector-aligned, i.e., (n * 0x200) */++#define ABS_PSP(x) (x-_start-0x100)+#define ABS_START(x) (x-_start-0x200)+#define ABS_FINAL(x) (x-_start-DOSSTART_SIZE+0x200)++#define exe_last_sector_size ((STAGE2_SIZE + DOSSTART_SIZE) % 512)+#define exe_sectors ((STAGE2_SIZE + DOSSTART_SIZE + 511) / 512 )+	+	.file	"dosstart.S"++	.text++	/* Tell GAS to generate 16-bit instructions so that this code works+	   in real mode. */+	.code16++	.globl	start, _start+start:+_start:+	/*+	 * The dos startup code counts 5 sectors:+	 *+	 * 1 sector for DOS EXE header, followed by 4 sectors of code.+	 * Of the 4 code sectors, the first 3 sectors are preparational+	 * sectors, and the last sector is called the FINAL sector. The+	 * FINAL sector contains code that finally launches the stage2 code.+	 * So pay special attention to the FINAL sector. Do not destroy+	 * the FINAL sector upon memory move operations.+	 */++	.byte 0x4d, 0x5a	/* 'MZ', the EXE magic number.  */+	.word exe_last_sector_size /* EXE file last sector in bytes */+	.word exe_sectors	/* total sectors the EXE file occupies */+	.word 0			/* relocation table entries */+	.word 0x0020		/* header size in 16-byte sections.+					0x0020 sections == 512 bytes */+	.word 0x0400		/* MinAlloc sections, 16KByte room for+					extended BIOS data area */+	.word 0x0400		/* MaxAlloc sections, no more memory needed,+					so MaxAlloc == MinAlloc */+	.word 0			/* initial SS, relative to the so-called START+					segment */+	.word ABS_START(just_here) /* initial SP, points to displacement 0x180+					in the FINAL sector */+	.word 0			/* checksum, ignored by dos */+	.word 0			/* initial IP */+	.word 0			/* initial CS, relative to START segment */+	.word 0x0020		/* displacement of the relocation table */+	.word 0			/* overlay serial number. 0 for main program */++	. = 0x200	/* program goes here, DS==ES==PSP, CS==SS==START */++	cli		/* we have not much room for stack, so we cli */++	movw	$0x0081, %di	/* get command line */+	movw	$0x007f, %cx	/* max length of command line */+	movb	$0x20, %al	/* the space bar character */+	cld			/* scan upward */+	repz scasb		/* skip all space chars */+	decw	%di		/* points to the command line arguments */+	cmpb	$0x0d, (%di)	/* CR char means empty command line */+	jz	use_default_config_file+	movw	$ABS_PSP(option_config_file), %si+	movw	$0x000e, %cx+	cld+	repz cmpsb+	jnz	invalid_option+	movw	%di, %si	/* points to the config file name */+	movw	$0x007f, %cx+	movb	$0x0d, %al	/* find the end of command line, CR */+	cld+	repnz scasb+	movw	%di, %cx	/* points to config file name in stage2 */+	subw	%si, %cx+	decw	%cx		/* length of config file name */++put_config_file_name:+	pushw	%cx+	movw	$0x0010, %cx	/* set max length of grub version string */+	movw	$ABS_PSP(end_dosstart+0x12), %di /* version string */+	xorb	%al, %al	/* 0 means the end of the string */+	cld+	repnz scasb+	popw	%cx++	movw	%cx, %ax+	addw	%di, %ax+	cmpw	$ABS_PSP(end_dosstart+0x6f), %ax /* check for possible+						buffer overflow */+	jnb	file_name_too_long+	cld+	repz movsb		/* now it is safe, perform the move */+	xorb	%al, %al	/* write an end-of-string mark */+	movb	%al, (%di)	/*       to the new config file name */+	+	smsw	%ax		/* the old 286 code, save MSW to AX */+	testb	$0x01, %al	/* is it in protected mode? */+	jnz	protected_mode++	jmp	guess_DOS_versions /* OK. continues the second step */++use_default_config_file:+	movw	$ABS_PSP(option_config_file + 0x0e), %si+	movw	$0x001a, %cx+	jmp	put_config_file_name++invalid_option:+	movw	$ABS_PSP(usage_string), %dx++message_exit:+	movb	$0x09, %ah	/* display a dollar teminated string */+	int	$0x21		/* call DOS */+	movw	$0x4c01, %ax	/* exit with error number 01 */+	int	$0x21		/* call DOS */++program_hangs: /* should not get here, just in case int 21/4c01 would fail */+	jmp	program_hangs++protected_mode:+	movw	$ABS_PSP(protected_string), %dx+	jmp	message_exit++file_name_too_long:+	movw	$ABS_PSP(fatal_string), %dx+	jmp	message_exit+	+mapped_int13_vector_BIOS:+	.long 0+	.long 0+/* stage2_64K_pages: */+	.word (STAGE2_SIZE + 0x200 + 0xffff) >> 16++usage_string: /* DOS string terminator is dollar($), not the null char */+	.ascii "\r\nUsage:\r\n\tGRUB --config-file=FILE\r\n"+	.ascii "The options are case-sensitive, you must use lower-case "+	.ascii "letters. Example:\r\n\tGRUB "+option_config_file:+	.ascii "--config-file=(hd0,0)/boot/grub/menu.lst\r\n$"+protected_string:+	.ascii "\r\n\r\nCannot run in protected mode. Must run in real mode.\r\n\r\n$"+fatal_string:+	.ascii "\r\nFatal error: filename too long!\r\n$"+dos_unsupport_string:+	.ascii "\r\nSorry! Currently supported DOS versions are: MS-DOS 3.30 and later; FreeDOS\r\nkernel build 2029 and 2032, and, hopefully, any later FreeDOS versions.\r\n\r\nPrograms such as TSRs and device drivers may also change the BIOS interrupt\r\nvector table. Make sure those programs are not running, then try again.\r\n$"++check_a_range_of_ROM_vectors:+	cld+	lodsl+	cmpl	$0xC0000000, %eax /* ROM vectors assumed to be above C000:0 */+	jb	1f	/* check failed, with carry */+	loop	check_a_range_of_ROM_vectors+	clc		/* check passed, with no carry */+1:	ret++guess_DOS_versions:+	/* check for MS-DOS 7.0+ */+	+	xorw	%ax, %ax+	movw	%ax, %ds++	movw	$0x0560, %si /* begins the int 08 vector */+	movw	$0x0008, %cx /* 8 vectors to check, from int 08 to 0f */+	call	check_a_range_of_ROM_vectors+	jc	failed_check_msdos7plus++	movw	$0x05dc, %si /* begins the int 70 vector */+	movw	$0x0008, %cx /* 8 vectors to check, from int 70 to 77 */+	call	check_a_range_of_ROM_vectors+	jc	failed_check_msdos7plus+	+	movw	$0x05a4, %si /* the int 19 vector(?) must be 0 */+	cld+	lodsl+	orl	%eax, %eax+	jnz	failed_check_msdos7plus++	movw	$0x05d4, %si /* the int 4b vector must be preserved */+	cld+	lodsl+	movl	%eax, %ebx+	movw	$0x012c, %si /* the int 4b vector in place */+	cld+	lodsl+	cmpl	%ebx, %eax+	jnz	failed_check_msdos7plus++	movw	$0x081e, %si /* another saved int 08 vector */+	cld+	lodsb

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -