📄 grub-0.95-patch1-startups
字号:
++ movw $16, %cx+ xorw %bx, %bx+ xorw %dx, %dx+1:+ lodsw+ cmpw $0xbb53, %ax /* 0x53="pushw %bx",0xbb="movw $????,%bx" */+ jnz failed_check_freedos+ lodsw+ cmpw %ax, %bx+ jnz failed_check_freedos+ addw $4, %bx+ cmpw $1, %cx+ jz 2f+ lodsb+ cmpb $0xeb, %al /* 0xeb="jmp ????" */+ jnz failed_check_freedos+ lodsb+ orw %dx, %dx+ jnz 3f+ movw %si, %dx+ xorb %ah, %ah+ addw %ax, %dx+ jc failed_check_freedos+ jmp 2f+3:+ xorb %ah, %ah+ addw %si, %ax+ jc failed_check_freedos+ cmpw %ax, %dx+ jnz failed_check_freedos+2:+ loop 1b++ addw $0x0025, %si+ lodsb+ cmpb $0x9c, %al /* 0x9c="pushfw" */+ jnz failed_check_freedos+ lodsw+ cmpw $0x9fff, %ax /* 0x9fff="call far [bx+????]" */+ jnz failed_check_freedos+ lodsw+ /*xorl %esi, %esi*/+ movw %ax, %si /* DS:SI begins old int 08-0f,70-77 vectors */+ movw %ds, %ax+ orb %ah, %ah+ jnz failed_check_freedos+ shlw $4, %ax+ addw %ax, %si /* 0000:SI begins the above int08-77vectors */+ jc failed_check_freedos+ + + xorw %ax, %ax+ movw %ax, %ds+ /*movw $0x08a4, %si*/ /* int 08-0f,70-77 begins here */+ movw $0x0010, %cx /* 16 vectors to check */+ pushw %si+ call check_a_range_of_ROM_vectors+ popw %si+ jc failed_check_freedos++ pushw %si+ call restore_BDA_EBDA+ popw %si+ cli+ xorw %ax, %ax+ movw %ax, %es+ movw %ax, %ds+ /*movw $0x08a4, %si*/+ movw $0x0020, %di /* int 08 to 0f */+ movw $0x0010, %cx /* 16 words to move */+ cld+ repz movsw+ movw $0x01c0, %di /* int 70 to 77 */+ movw $0x0010, %cx /* 16 words to move */+ cld+ repz movsw+ + /*+ * MS himem.sys takes over int 15, so try to restore it+ */+ + movw $0x0054, %di+ movl (%di), %eax /* int 15 vector in table */+ cmpl $0xc0000000, %eax /* is it a valid BIOS vector? */+ jnb 1f /* yes, do nothing */+ movw $0x3086, %si /* no, take one from himem */+ movl (%si), %eax+ cmpl $0xc0000000, %eax /* is it a system BIOS vector? */+ jb 1f /* no, do nothing */+ movl %eax, (%di) /* yes, write it to the table */+1:+ jmp move_stage2_image++failed_check_freedos:+ /* check for DOSbox */+ + xorw %ax, %ax+ movw %ax, %ds+ movw $0x0020, %si /* int 08-1f */+ movw $0x0018, %cx /* 24 vectors to check */+ pushw %si+ call check_a_range_of_ROM_vectors+ popw %si+ jc failed_check_dosbox++ pushw %si+ call restore_BDA_EBDA+ popw %si+#if 0+ cli+ xorw %ax, %ax+ movw %ax, %es+ movw %ax, %ds+ /*movw $0x08a4, %si*/+ movw $0x0020, %di /* int 08 to 0f */+ movw $0x0010, %cx /* 16 words to move */+ cld+ repz movsw+ movw $0x01c0, %di /* int 70 to 77 */+ movw $0x0010, %cx /* 16 words to move */+ cld+ repz movsw+#endif+ + jmp move_stage2_image++failed_check_dosbox:+ movw %cs, %ax+ movw %ax, %ds+ movw $ABS_START(dos_unsupport_string), %dx+ jmp message_exit++restore_BDA_EBDA:+ cli+ cld+ xorw %ax, %ax+ movw %ax, %ds+ movw $0x040e, %si /* points to EBDA segment */+ lodsw+ orw %ax, %ax /* is EBDA segment? */+ jz invalid_EBDA /* no EBDA exists */+ movw %ax, %cx+ movw $0x0413, %si /* points to conventional memory size in KB */+ lodsw+ cmpw $0x0280, %ax /* 0x280 == 640 */+ ja invalid_EBDA /* too much conventional memory */+ shlw $0x06, %ax+ movw %ax, %dx /* conventional memory size in sections */+ movw %cx, %ds /* DOS currently used EBDA segment */+ xorw %si, %si /* the first byte of the EBDA ... */+ lodsb /* ...is the EBDA size in KB */+ cmpb $0x08, %al /* EBDA size greater than 8K ? */+ ja invalid_EBDA /* EBDA too large */+ orb %al, %al /* EBDA size is 0 ? */+ jz invalid_EBDA /* EBDA should not be 0 in length */+ movw $0x0280, %bx+ subb %al, %bl /* BX is the calculated low mem in K */+ shlw $0x06, %bx /* BX is the calculated EBDA segment */+ cmpw %bx, %cx /* CX is currently used EBDA segment */+ jb 1f /* jump if below the normal address */++ /* BX should be equal to CX, DX holds the segment at low mem end,+ * Thus, DX should be less than or equal to BX+ */+ + /* restore vectors in the range from DX:0 to BX:0, + * EBDA need not be restored+ */+ movw %cs, %ax+ movw %ax, %es+ movw $ABS_START(mapped_int13_vector_BIOS), %di+ movw %dx, %ax /* AX is currently used low mem in sections */+ stosw+ movw %bx, %ax+ shrw $6, %ax /* AX is the calculated low mem in K */+ stosw+ movw %di, %bp+ movw %dx, %es+ xorw %di, %di+ movw $0x0400, %cx+ movb $0x9a, %al /* 0x9a == lcall */+3:+ repnz scasb+ jcxz 2f+ cmpl $0x9a006e8b, %es:-4(%di) /* movw (%bp), %bp; lcall */+ jnz 3b+ movw %di, %si+ movw %bp, %di+ movw %es, %ax+ movw %ax, %ds+ movw %cs, %ax+ movw %ax, %es+ lodsl+ cmpl $0xc0000000, %eax+ jb 2f+ stosl /* save the original BIOS int13 vector */+ +2:+ ret+ +1:+ /* Restore vectors in the range from DX:0 to A000:0 + * No vectors need to be restored because DX seems always be 0xA000+ */+ movw %bx, %es /* ES is the calculated EBDA segment */+ shlw $9, %ax /* AX *= 512 */+ movw %ax, %cx /* EBDA size in words */+ decw %ax+ shlw $1, %ax /* points to the last word in EBDA */+ movw %ax, %si /* DS holds the currently used EBDA segment */+ movw %ax, %di /* ES holds the calculated EBDA segment */+ std /* move higher word first */+ repz movsw /* move to BIOS EBDA */+ cld+ xorw %ax, %ax+ movw %ax, %es /* DI string operations use ES == 0 */+ movw %bx, %ax+ movw $0x040e, %di+ stosw /* restore the BDA pointer of EBDA segment */+ movw $0x0413, %di+ shrw $6, %ax+ stosw /* restore the BDA field of low mem size */+ ret++invalid_EBDA:+ xorw %ax, %ax /* AX == 0 means invalid EBDA segment */+ movw %ax, %es /* DI string operations use ES == 0 */+ movw $0x040e, %di /* let EBDA segment be invalid */+ stosw /* store 0 to 0000:040e */+ movw $0x0413, %di /* let lower memory size at 0x413 ... */+ movw $0x0280, %ax /* ... be 640K (0x280 == 640) */+ stosw /* store 640 to 0000:0413 */+ ret++move_stage2_image:++#if 0+ /* open video */+ + movw $0x1200, %ax+ movb $0x32, %bl+ int $0x10++ movb $0x0f, %ah /* get current display mode */+ int $0x10+ + xorb %ah, %ah+ andb $0x7f, %al+#endif++#if 1++ movw $0x0003, %ax /* set display mode: 80*25 color text */+ int $0x10++#endif++#if 0+ /* reset int 20-3f */+ + xorw %ax, %ax+ movw %ax, %ds+ movw %ax, %es+ movw $0x0070, %si /* BIOS int 1c points to IRET */+ lodsl+ movl $0xf000ef6f, %eax+ xorl %eax, %eax+ movw $0x0080, %di+ movw $0x0020, %cx+ rep stosl+#endif++ movw %cs, %ax+ movw %ax, %ds++#if 1 + /* restore mapped int13 */+ + movw $ABS_START(mapped_int13_vector_BIOS), %si+ + xorw %ax, %ax+ movw %ax, %es+ lodsl+ movl %eax, %ecx+ lodsl+ testl %eax, %eax+ jz 1f+ movw $0x004c, %di /* int13 */+ movl %es:(%di), %ebx+ testw %bx, %bx+ jnz 1f+ shrl $16, %ebx+ cmpw %cx, %bx+ jnz 1f+ stosl /* write to 0000:004c */+ shrl $16, %ecx+ movw $0x0413, %di+ movw %cx, %ax+ stosw /* write to 0000:0413 */+1:+#endif++ /* movw $ABS_START(stage2_64K_pages), %si */+ movw (%si), %cx++ movw %cs, %ax+ addw $(ABS_START(end_dosstart-0x200)/0x10), %ax+ movw %ax, %bx /* save the final stage2 segment to %bx */+ cmpw $0x0800, %ax+ ja 2f+1:+ xorw %ax, %ax+ movb %cl, %ah+ decb %ah+ shlb $0x04, %ah+ movw %bx, %dx+ addw %ax, %dx+ movw %dx, %ds+ addb $0x08, %ah /* addw $0x0800, %ax */+ movw %ax, %es+ movw $0xfffe, %si+ movw %si, %di+ movw %cx, %dx /* save %cx to %dx */+ movw $0x8000, %cx /* 0x8000 words == 64K bytes */+ cmpw $0x0001, %dx /* do not move the sector containing this+ code, to ensure no overlap */+ ja 3f+ decb %ch /* %cx == 0x7f00 */+3:+ cli+ std /* move from higher end to lower end */+ repz movsw+ movw %dx, %cx /* restore %cx from %dx */+ loop 1b++ jmp launch_stage2_code+ +2:+ xorw %si, %si+ xorw %di, %di+ movw $0x07e0, %ax /* use 7e0 other than 800 to ensure no overlap */+ movw %ax, %es+ movw %bx, %ds+ movw %cx, %dx /* save %cx to %dx */+ movw $0x0100, %cx /* move the sector containing this code */+ cli+ xorw %ax, %ax+ movw %ax, %ss+ movw $0x2000, %sp+ cld+ repz movsw+ movw %dx, %cx /* restore %cx from %dx */+ ljmp $0x07e0, $ABS_FINAL(just_here)+ + . = (DOSSTART_SIZE - 0x0100)++ /* room for stack, 0x80 bytes */++ . = (DOSSTART_SIZE - 0x0080)+just_here: /* from here on, code must be in the FINAL sector */++ movw $0x0800, %ax+ movw %ax, %es+ movw %bx, %ds+1:+ xorw %si, %si+ xorw %di, %di+ movw %cx, %dx /* save %cx to %dx */+ movw $0x8000, %cx /* 0x8000 words == 64K bytes */+ cld+ repz movsw+ movw %dx, %cx /* restore %cx from %dx */+ addw $0x1000, %ax /* move the next 64K-byte page */+ movw %ax, %es+ addw $0x1000, %bx+ movw %bx, %ds+ loop 1b++launch_stage2_code:+ cli+ cld+ xorw %ax, %ax+ movw %ax, %ds+ movw %ax, %es+ movw %ax, %ss+ movw $0x2000, %sp+ movw %ax, %dx /* %dl == 0 means floppy, thus save-default-+ config-file-entry-number will do nothing */+ xorl %ebp, %ebp+ xorl %esi, %esi+ sti /* safe now, just before transferring control */+ ljmp $0, $0x8200+ + . = (DOSSTART_SIZE - 1)+ .ascii "$" /* no use, just stops a possible endless DOS string */+end_dosstart:+diff -Naur grub-0.95/stage2/edd.S grub-0.95_startups/stage2/edd.S--- grub-0.95/stage2/edd.S 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_startups/stage2/edd.S 2004-10-21 22:40:07.379284000 +0800@@ -0,0 +1,138 @@+/*+ * BIOS Enhanced Disk Drive support+ * by Matt Domsch <Matt_Domsch@dell.com> October 2002+ * conformant to T13 Committee www.t13.org+ * projects 1572D, 1484D, 1386D, 1226DT+ * disk signature read by Matt Domsch <Matt_Domsch@dell.com>+ * and Andrew Wilks <Andrew_Wilks@dell.com> September 2003, June 2004+ * legacy CHS retreival by Patrick J. LoPresti <patl@users.sourceforge.net>+ * March 2004+ */++#include <linux/edd.h>++#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)+# Read the first sector of each BIOS disk device and store the 4-byte signature+edd_mbr_sig_start:+ movb $0, (EDD_MBR_SIG_NR_BUF) # zero value at EDD_MBR_SIG_NR_BUF+ movb $0x80, %dl # from device 80+ movw $EDD_MBR_SIG_BUF, %bx # store buffer ptr in bx+edd_mbr_sig_read:+ movl $0xFFFFFFFF, %eax+ movl %eax, (%bx) # assume failure+ pushw %bx+ movb $READ_SECTORS, %ah+ movb $1, %al # read 1 sector+ movb $0, %dh # at head 0+ movw $1, %cx # cylinder 0, sector 0+ pushw %es+ pushw %ds+ popw %es+ movw $EDDBUF, %bx # disk's data goes into EDDBUF+ pushw %dx # work around buggy BIOSes+ stc # work around buggy BIOSes+ int $0x13+ sti # work around buggy BIOSes+ popw %dx+ popw %es+ popw %bx+ jc edd_mbr_sig_done # on failure, we're done.+ movl (EDDBUF+EDD_MBR_SIG_OFFSET), %eax # read sig out of the MBR+ movl %eax, (%bx) # store success+ incb (EDD_MBR_SIG_NR_BUF) # note that we stored something+ incb %dl # increment to next device+ addw $4, %bx # increment sig buffer ptr+ cmpb $EDD_MBR_SIG_MAX, (EDD_MBR_SIG_NR_BUF) # Out of space?+ jb edd_mbr_sig_read # keep looping+edd_mbr_sig_done:++# Do the BIOS Enhanced Disk Drive calls+# This consists of two calls:+# int 13h ah=41h "Check Extensions Present"+# int 13h ah=48h "Get Device Parameters"+# int 13h ah=08h "Legacy Get Device Parameters"+#+# A buffer of size EDDMAXNR*(EDDEXTSIZE+EDDPARMSIZE) is reserved for our use+# in the boot_params at EDDBUF. The first four bytes of which are+# used to store the device number, interface support map and version+# results from fn41. The next four bytes are used to store the legacy+# cylinders, heads, and sectors from fn08. The following 74 bytes are used to+# store the results from fn48. Starting from device 80h, fn41, then fn48+# are called and their results stored in EDDBUF+n*(EDDEXTSIZE+EDDPARMIZE).+# Then the pointer is incremented to store the data for the next call.+# This repeats until either a device doesn't exist, or until EDDMAXNR+# devices have been stored.+# The one tricky part is that ds:si always points EDDEXTSIZE bytes into+# the structure, and the fn41 and fn08 results are stored at offsets+# from there. This removes the need to increment the pointer for+# every store, and leaves it ready for the fn48 call.+# A second one-byte buffer, EDDNR, in the boot_params stores+# the number of BIOS devices which exist, up to EDDMAXNR.+# In setup.c, copy_edd() stores both boot_params buffers away+# for later use, as they would get overwritten otherwise.+# This code is sensitive to the size of the structs in edd.h+edd_start:+ # %ds points to the bootsector+ # result buffer for fn48+ movw $EDDBUF+EDDEXTSIZE, %si # in ds:si, fn41 results+ # kept just before that+ movb $0, (EDDNR) # zero value at EDDNR+ movb $0x80, %dl # BIOS device 0x80++edd_check_ext:+ movb $CHECKEXTENSIONSPRESENT, %ah # Function 41+ movw $EDDMAGIC1, %bx # magic+ int $0x13 # make the call+ jc edd_done # no more BIOS devices++ cmpw $EDDMAGIC2, %bx # is magic right?+ jne edd_next # nope, next...++ movb %dl, %ds:-8(%si) # store device number+ movb %ah, %ds:-7(%si) # store version+ movw %cx, %ds:-6(%si) # store extensions+ incb (EDDNR) # note that we stored something++edd_get_device_params:+ movw $EDDPARMSIZE, %ds:(%si) # put size+ movw $0x0, %ds:2(%si) # work around buggy BIOSes+ movb $GETDEVICEPARAMETERS, %ah # Function 48+ int $0x13 # make the call+ # Don't check for fail return+ # it doesn't matter.+edd_get_legacy_chs:+ xorw %ax, %ax+ movw %ax, %ds:-4(%si)+ movw %ax, %ds:-2(%si)+ # Ralf Brown's Interrupt List says to set ES:DI to+ # 0000h:0000h "to guard against BIOS bugs"+ pushw %es+ movw %ax, %es+ movw %ax, %di+ pushw %dx # legacy call clobbers %dl+ movb $LEGACYGETDEVICEPARAMETERS, %ah # Function 08+ int $0x13 # make the call+ jc edd_legacy_done # failed+ movb %cl, %al # Low 6 bits are max+ andb $0x3F, %al # sector number+ movb %al, %ds:-1(%si) # Record max sect+ movb %dh, %ds:-2(%si) # Record max head number+ movb %ch, %al # Low 8 bits of max cyl+ shr $6, %cl+ movb %cl, %ah # High 2 bits of max cyl+ movw %ax, %ds:-4(%si)++edd_legacy_done:+ popw %dx+ popw %es+ movw %si, %ax # increment si+ addw $EDDPARMSIZE+EDDEXTSIZE, %ax+ movw %ax, %si++edd_next:+ incb %dl # increment to next device+ cmpb $EDDMAXNR, (EDDNR) # Out of space?+ jb edd_check_ext # keep looping++edd_done:+#endifdiff -Naur grub-0.95/stage2/grldrstart.S grub-0.95_startups/stage2/grldrstart.S--- grub-0.95/stage2/grldrstart.S 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_startups/stage2/grldrstart.S 2004-10-10 03:09:14.000000000 +0800@@ -0,0 +1,1823 @@+/*+ * grldrstart.S -- Startup code for GRLDR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -