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

📄 grub-0.93-diff

📁 从linux移植到dos下的grub
💻 93-DIFF
📖 第 1 页 / 共 4 页
字号:
diff -Naur grub-0.93/stage2/asm.S grub-0.93_dos/stage2/asm.S--- grub-0.93/stage2/asm.S	2002-12-02 23:18:56.000000000 +0000+++ grub-0.93_dos/stage2/asm.S	2003-09-23 14:50:12.000000000 +0000@@ -612,7 +612,7 @@ 	pushl	%esi  	/* copy MAP to the drive map */-	movl	$(DRIVE_MAP_SIZE * 2), %ecx+	movl	$(DRIVE_MAP_SIZE * 10), %ecx 	movl	$ABS(drive_map), %edi 	movl	8(%ebp), %esi 	cld@@ -656,13 +656,17 @@  	 /* - * Map a drive to another drive.+ * Map a drive to another drive or disk image file.  */ 	 	.code16 	 int13_handler:-	pushw	%ax+#if 0+	/* for test only - direct far jmp to original int13 */+	ljmp	%cs:*(int13_offset - int13_handler)+#endif+	pushl	%eax 	pushw	%bp 	movw	%sp, %bp 	@@ -672,59 +676,314 @@ 	movw	$(drive_map - int13_handler), %si 	/* find the drive number from the drive map */ 	cld+	subw	$0x0a, %sp 1:	+	addw	$0x0a, %sp 	lodsw	%cs:(%si), %ax+	pushw	%ax+	lodsl	%cs:(%si), %eax+	pushl	%eax+	lodsl	%cs:(%si), %eax+	notl	%eax+	pushl	%eax++	movw	-4(%bp), %ax+ 	/* check if this is the end */ 	testw	%ax, %ax-	jz	2f-	/* check if this matches the drive number */-	cmpb	%al, %dl-	jne	1b-	/* if so, perform the mapping */+	jnz	3f	/* not end, continue */+	movl	-8(%bp), %eax+	testl	%eax, %eax+	jnz	3f	/* not end, continue */+	movl	-12(%bp), %eax+	notl	%eax+	testl	%eax, %eax+	jz	2f	/* drive map to itself with write permission, +				signals the end */+3:+	movw	-4(%bp), %ax+	cmpb	%al, %dl	/* check if this matches the drive number */+	jne	1b		/* no, continue to check the next map */++	movl	-8(%bp), %eax+	testl	%eax, %eax+	jnz	4f	/* drive emulation */+	movl	-12(%bp), %eax+	notl	%eax+	shrl	$1, %eax+	jnz	4f	/* drive emulation */+	jnc	1f	/* with write permission */+	+	call	readonly_map+1:+	/* now a simple drive map, with write permission */+	movw	-4(%bp), %ax 	movb	%ah, %dl 2:-	/* restore %si */-	popw	%si-	/* save %ax in the stack */-	pushw	%ax-	/* simulate the interrupt call */-	pushw	8(%bp)-	/* set %ax and %bp to the original values */-	movw	2(%bp), %ax-	movw	(%bp), %bp-	/* lcall */-	.byte	0x9a+	/* now a simple drive map, drive may be acturally mapped or not */+	+	movw	-2(%bp), %si	/* restore %si */++	pushw	10(%bp)		/* pushfw, simulate the interrupt call */+	+	movl	2(%bp), %eax	/* restore %eax */+	movw	(%bp), %bp	/* restore %bp */+	.byte	0x9a		/* lcall, simulate the interrupt call */ int13_offset:	.word	0 int13_segment:	.word	0-	/* save flags */-	pushf-	/* restore %bp */-	movw	%sp, %bp-	/* save %ax */-	pushw	%ax-	/* set the flags in the stack to the value returned by int13 */-	movw	(%bp), %ax-	movw	%ax, 0xc(%bp)-	/* check if should map the drive number */-	movw	6(%bp), %ax-	cmpw	$0x8, %ax-	jne	3f-	cmpw	$0x15, %ax-	jne	3f-	/* check if the mapping was performed */-	movw	2(%bp), %ax-	testw	%ax, %ax-	jz	3f-	/* perform the mapping */-	movb	%al, %dl+	pushw	%ax		/* save %ax */+	pushfw			/* save flags returned by int13 */+	popw	%ax+	movw	%sp, %bp	/* set new %bp */+	movw	%ax, 24(%bp)	/* update the flags in the stack */+	+	/* check if should restore(reversely map) the drive number */+	jc	1f		/* restore %dl on error */+	movw	16(%bp), %ax	/* lower word of the saved %eax */+	cmpb	$0x08, %ah	/* int13 AH=08h, read drive parameters */+	je	3f		/* DL==number of drives, should not restore */+	cmpb	$0x15, %ah	/* int13 AH=15h, read drive type */+	je	3f		/* CX:DX==total sectors, should not restore */+1:+	/* try to restore %dl if possible */+	movw	10(%bp), %ax	/* get the drive mapping */+	cmpb	%al, %ah	/* check if the mapping was performed */+	je	3f		/* not performed, so need not restore %dl */+	cmpb	%dl, %ah+	jne	3f		/* %dl changed by int13, so do not restore */+	movb	%al, %dl	/* restore %dl to the value before mapping */ 3: 	popw	%ax-	movw	4(%bp), %bp-	addw	$8, %sp+	movw	14(%bp), %bp+	addw	$18, %sp 	iret+	+readonly_map:+	movw	2(%bp), %ax	/* lower word of the saved %eax */+	cmpb	$0x03, %ah	/* write sectors */+	je	1f+	cmpb	$0x05, %ah	/* PC/XT/AT/EISA format tracks */+	je	1f+	cmpb	$0x06, %ah	/* PC/XT format tracks with bad sectors */+	je	1f+	cmpb	$0x07, %ah	/* PC/XT format multiple cylinders */+	je	1f+	cmpb	$0x0b, %ah	/* PC/XT/AT/EISA write sectors with ECC */+	je	1f+	cmpb	$0x0f, %ah	/* PC/XT/PS/1 write sector buffer */+	je	1f+	cmpb	$0x1a, %ah	/* PS/2 format ESDI drive */+	je	1f+	cmpb	$0x22, %ah	/* PS/1 write multi-group sectors */+	je	1f+	cmpb	$0x43, %ah	/* EBIOS extended write sector */+	je	1f+	ret	/* other functions are not write protected, ret and continue */+1:+	movw	-2(%bp), %si	/* restore the original %si */+	movl	2(%bp), %eax	/* restore the original %eax */+	movw	(%bp), %bp	/* restore the original %bp */+	movb	$0x03, %ah	/* signal write protection */+	addw	$20, %sp	/* adjust %sp */+	stc			/* signal error */+	lret	$2		/* far return discard the original flags */++4:+	testb	$1, -12(%bp)+	jnz	1f	/* with write permission */+	+	call	readonly_map+1:+	/* drive emulation */+	cmpb	$0x80, %dl+	jb	5f	/* floppy */+	/* hard disk */+2:+	jmp	2b +5:+	movw	2(%bp),	%ax	/* get original AX */+	testb	%ah, %ah+	jnz	1f+	clc		/* reset disk, always succeed */+	jmp	9f+1:+	cmpb	$0x01, %ah+	jnz	1f+	xorb	%ah, %ah	/* get status, always succeed */+	clc+	jmp	9f+1:+	cmpb	$0x04, %ah+	jnz	1f+	xorb	%ah, %ah	/* check sectors, always succeed */+	clc+	jmp	9f+1:+	cmpb	$0x03, %ah	/* write sectors */+	jnz	1f+	movb	$0x03, %ah	/* failure, write protection */+	stc+	jmp	9f+1:+	cmpb	$0x05, %ah	/* format track */+	jnz	1f+	movb	$0x03, %ah	/* failure, write protection */+	stc+	jmp	9f+1:+	cmpb	$0x08, %ah	/* get parameter */+	jnz	1f+	xorb	%bh, %bh+	movb	$0x04, %bl+	movw	$0x4f12, %cx+	movw	$0x0101, %dx+	xorw	%ax, %ax+	movw	%ax, %es+	movw	$0x0078, %di+	movl	%es:(%di), %eax+	movw	%ax, %di+	shrl	$0x10, %eax+	movw	%ax, %es+	xorw	%ax, %ax+	clc+	jmp	9f+1:+	cmpb	$0x15, %ah+	jnz	1f+	movb	$0x02, %ah	/* support change line */+	clc+	jmp	9f+1:+	cmpb	$0x16, %ah+	jnz	1f+	xorb	%ah, %ah	/* not changed */+	clc+	jmp	9f+1:+	cmpb	$0x17, %ah+	jnz	1f+	movb	$0x03, %al	/* 1.44M drive, 1.44M floppy */+	xorb	%ah, %ah+	clc+	jmp	9f+1:+	cmpb	$0x18, %ah	/* set floppy type for format */+	jnz	1f+	pushw	%ax+	xorw	%ax, %ax+	movw	%ax, %es+	movw	$0x0078, %di+	movl	%es:(%di), %eax+	movw	%ax, %di+	shrl	$0x10, %eax+	movw	%ax, %es+	popw	%ax+	xorb	%ah, %ah+	clc+	jmp	9f+1:+	cmpb	$0x02, %ah	/* read sectors */+	jnz	1f+	cmpb	$0x7F, %al	/* check if sectors exceed 127 */+	ja	1f+	testb	%al, %al	/* read 0 sectors not allowed */+	jz	1f+	testb	$0xc0, %cl	/* 1.44M floppy cylinder less than 10 bits */+	jnz	1f+	testb	%cl, %cl	/* beginning sector number 0 is invalid */+	jz	1f+	cmpb	$0x12, %cl	/* 1.44M floppy max sector number == 18 */+	ja	1f+	cmpb	$0x01, %dh	/* 1.44M floppy max head number == 1 */+	ja	1f+	cmpb	$0x4F, %ch	/* 1.44M floppy max cylinder number == 79 */+	ja	1f+	pushw	%ds+	pushw	%cs+	popw	%ds+	movw	$(EBIOS_disk_address_packet - int13_handler), %si+	movb	%al, 2(%si)	/* sectors, FIXME: need to check range */+	movw	%bx, 4(%si)+	movw	%es, 6(%si)+	movb	%ch, %al	/* track/cylinder number */+	movb	%cl, %ah	/* CL holds higher 2 bits */+	shrb	$6, %ah		/* AH lower holds the 2 bits */+				/* Now AX holds the 10 bit cylinder number */+	shlw	$1, %ax		/* mul 2, which is the MaxHeads for floppy */+	addb	%dh, %al	/* add DH to AX, no carry since DH <= 1 */+	movw	$0x0012, %dx+	mulw	%dx+	test	%dx, %dx+	jz	2f+3:+	jmp	3b+2:+	movw	%dx, 0x0a(%si)	/* DX == 0 */+	andb	$63, %cl	/* beginning sector number */+	decb	%cl+	addb	%cl, %dl+	addw	%dx, %ax+	movw	%ax, 0x08(%si)+	+	xorl	%eax, %eax+	movl	%eax, 0x0c(%si)+	movl	-8(%bp), %eax+	addl	%eax, 0x08(%si)+	jnc	3f+	incl	0x0c(%si)+3:+	/* need to check the range */+	movw	-4(%bp), %ax+	movb	%ah, %dl+	movb	$0x42, %ah	/* extended read sectors */+#if 0+	pushw	%bp+	pushw	%si+#endif+	pushfw+	lcall	*(int13_offset - int13_handler)	/* call original int13 */+#if 0+	popw	%si+	popw	%bp+#endif+	movb	2(%si), %al	/* restore AL */+	movw	-2(%bp), %si	/* restore the original %si */+	popw	%ds+	/* need to restore DL */+	movb	-4(%bp), %dl+	+	jmp	9f+1:+	movb	$0x01, %ah	/* unsupported function call */+	stc			/* signal error */+9:+	pushw	%ax		/* save status */+	pushfw+	popw	%ax+	movw	%ax, 10(%bp)	/* update flags in the stack */+	movw	-2(%bp), %si	/* restore the original %si */+	movl	2(%bp), %eax	/* restore the original %eax */+	movw	(%bp), %bp	/* restore the original %bp */+	popw	%ax		/* restore status */+	addw	$18, %sp	/* adjust %sp */+	iret+int13_handler_code_end:+#if 0 	.align	4-drive_map:	.space	(DRIVE_MAP_SIZE + 1) * 2+#else+	.space	(4 - ((int13_handler_code_end - int13_handler) % 4)) % 4+#endif+EBIOS_disk_address_packet:+	.byte	0x10	/* packet size, 16 or more */+	.byte	0	/* reserved, must be 0 */+	.byte	0	/* number of sectors, must be from 1 to 127 */+	.byte	0	/* reserved, must be 0 */+	.word	0	/* displacement of memory address */+	.word	0	/* segment of memory address */+	.long	0	/* 64bit, start logical sector number */+	.long	0+drive_map:	.space	(DRIVE_MAP_SIZE + 1) * 10 int13_handler_end: 	 	.code32diff -Naur grub-0.93/stage2/builtins.c grub-0.93_dos/stage2/builtins.c--- grub-0.93/stage2/builtins.c	2002-12-04 04:41:57.000000000 +0000+++ grub-0.93_dos/stage2/builtins.c	2003-09-23 14:50:13.000000000 +0000@@ -75,7 +75,27 @@ /* Whether to show the menu or not.  */ int show_menu = 1; /* The BIOS drive map.  */-static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];+struct drive_map_slot {+	unsigned short drive_map;+	+	/* compact form, should not use long directly */+	unsigned short start_sector;+	unsigned short start_sector_hi;+	+	/* compact form, should not use long directly */+	unsigned short sector_count;+	unsigned short sector_count_hi;+};+static struct drive_map_slot bios_drive_map[DRIVE_MAP_SIZE + 1];++static int+drive_map_slot_empty (struct drive_map_slot item)+{+	if (item.drive_map) return 0;+	if (*(unsigned long *)(&(item.start_sector))) return 0;+	if (*(unsigned long *)(&(item.sector_count))) return 0;+	return 1;+}  /* Prototypes for allowing straightfoward calling of builtins functions    inside other functions.  */@@ -128,7 +148,10 @@   grub_printf ("[%d,%d,%d]", sector, offset, length); } -+extern int rawread_ignore_memmove_overflow; /* defined in disk_io.c */+static int query_block_entries = 0;+static unsigned long map_start_sector = 0;+static unsigned long map_num_sectors = 0; /* blocklist */ static int blocklist_func (char *arg, int flags)@@ -138,6 +161,7 @@   int num_sectors = 0;   int num_entries = 0;   int last_length = 0;+  int err;    /* Collect contiguous blocks into one entry as many as possible,      and print the blocklist notation on the screen.  */@@ -154,6 +178,7 @@ 	    } 	  else 	    {+	      if (query_block_entries >= 0) 	      if (last_length == SECTOR_SIZE) 		grub_printf ("%s%d+%d", num_entries ? "," : "", 			     start_sector - part_start, num_sectors);@@ -172,6 +197,7 @@        if (offset > 0) 	{+	  if (query_block_entries >= 0) 	  grub_printf("%s%d[%d-%d]", num_entries ? "," : "", 		      sector-part_start, offset, offset+length); 	  num_entries++;@@ -184,39 +210,66 @@ 	}     } +  map_start_sector = 0;+  map_num_sectors = 0;+   /* Open the file.  */   if (! grub_open (arg))-    return 1;+    goto fail_open;    /* Print the device name.  */+  if (query_block_entries >= 0)   grub_printf ("(%cd%d", 	       (current_drive & 0x80) ? 'h' : 'f', 	       current_drive & ~0x80);      if ((current_partition & 0xFF0000) != 0xFF0000)+    if (query_block_entries >= 0)     grub_printf (",%d", (current_partition >> 16) & 0xFF);      if ((current_partition & 0x00FF00) != 0x00FF00)+    if (query_block_entries >= 0)     grub_printf (",%c", 'a' + ((current_partition >> 8) & 0xFF));   +  if (query_block_entries >= 0)

⌨️ 快捷键说明

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