📄 grub-0.97-patch1-startups
字号:
++ movl $8, %ecx+ movl $ABS(option_fat16), %esi+ movl %ebx, %edi++ cld+ repz cmpsb++ jnz 3f++ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ + cmpl $0xfffffff7, ABS(fstypes)+ jnz 2f+ movl $0, ABS(fstypes)+2:+ orb $2, ABS(fstypes)+ jmp 1b++3:++ /* check --fat32 */++ movl $8, %ecx+ movl $ABS(option_fat32), %esi+ movl %ebx, %edi++ cld+ repz cmpsb++ jnz 3f++ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ + cmpl $0xfffffff7, ABS(fstypes)+ jnz 2f+ movl $0, ABS(fstypes)+2:+ orb $4, ABS(fstypes)+ jmp 1b++3:++ /* check --ntfs */++ movl $7, %ecx+ movl $ABS(option_ntfs), %esi+ movl %ebx, %edi++ cld+ repz cmpsb++ jnz 3f++ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ + cmpl $0xfffffff7, ABS(fstypes)+ jnz 2f+ movl $0, ABS(fstypes)+2:+ orb $8, ABS(fstypes)+ jmp 1b++3:++ /* check --ext2 */++ movl $7, %ecx+ movl $ABS(option_ext2), %esi+ movl %ebx, %edi++ cld+ repz cmpsb++ jnz 3f++ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ + cmpl $0xfffffff7, ABS(fstypes)+ jnz 2f+ movl $0, ABS(fstypes)+2:+ orb $0x10, ABS(fstypes)+ jmp 1b++3:++ /* check --vfat */++ movl $7, %ecx+ movl $ABS(option_vfat), %esi+ movl %ebx, %edi++ cld+ repz cmpsb++ jnz 3f++ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ + cmpl $0xfffffff7, ABS(fstypes)+ jnz 2f+ movl $0, ABS(fstypes)+2:+ orb $7, ABS(fstypes)+ jmp 1b++3:++ movl $ABS(msg_invalid_option), %ecx+ jmp 4f /* error */++1:++//----------------------------------------------------------------------------+ /* end of arguments */++ /* ECX=EBX=0 */++ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ + testl %eax, %eax # filename already specified?+ //cmpl $0, ABS(filename) # filename already specified?+ movl $ABS(msg_no_file), %ecx+ jz 4f /* error */++ xchgl %eax, %ebx # move EAX to EBX+ //movl ABS(filename), %ebx # move filename to EBX++ /* EBX points to the pathname of the file. */++ /* check if preferred_partition matches preferred_drive */++ movb ABS(preferred_drive), %al+ movb ABS(preferred_partition), %ah++ cmpb $0xff, %al+ jne 1f++ movl %ebx, %edi # save EBX to EDI+ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ cmpb $0xff, %ah+ movl $ABS(msg_partition_without_drive), %ecx+ jne 4f /* error */+ movl %edi, %ebx # restore EBX from EDI+1:++ /* EBX points to the pathname of the file. */++ movl %ebx, %edi # save EBX to EDI+ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ + cmpl $0xffffffff, ABS(floppy)+ je 1f # --floppy is not specified++ /* if --floppy is specified, should not specify the options for MBR. */+ cmpl $1, ABS(backup_mbr)+ movl $ABS(msg_option_backup_mbr_with_floppy), %ecx+ jnz 4f /* error */++ cmpl $0, ABS(mbr_floppy)+ movl $ABS(msg_option_mbr_floppy_with_floppy), %ecx+ jnz 4f /* error */+ + cmpl $0, ABS(mbr_osbr)+ movl $ABS(msg_option_mbr_osbr_with_floppy), %ecx+ jnz 4f /* error */+ + cmpl $0, ABS(boot_prevmbr)+ movl $ABS(msg_option_boot_prevmbr_with_floppy), %ecx+ jnz 4f /* error */+ + cmpl $0xff, ABS(preferred_drive)+ movl $ABS(msg_option_preferred_drive_with_floppy), %ecx+ jnz 4f /* error */++ cmpl $0xff, ABS(preferred_partition)+ movl $ABS(msg_option_preferred_partition_with_floppy), %ecx+ jnz 4f /* error */++ cmpl $0xffffffff, ABS(install_partition)+ movl $ABS(msg_option_install_partition_with_floppy), %ecx+ jnz 4f /* error */++ cmpl $0xffffff05, ABS(time_out)+ movl $ABS(msg_option_time_out_with_floppy), %ecx+ jnz 4f /* error */++ cmpl $0xffff3920, ABS(hot_key)+ movl $ABS(msg_option_hot_key_with_floppy), %ecx+ jnz 4f /* error */+ + /* for a floppy, start_sector should be 0, and+ * for a partition, start_sector should be non-zero+ */+ cmpl $0xff, ABS(floppy)+ je 2f # a real floppy++ /* a single partition */+ cmpl $0, ABS(start_sector)+ movl $ABS(msg_partition_start), %ecx+ jz 4f /* error */++ jmp 3f +2:+ /* a real floppy */+ /* */+ cmpl $0xffffffff, ABS(start_sector)+ je 3f+ cmpl $0, ABS(start_sector)+ movl $ABS(msg_floppy_start), %ecx+ jnz 4f /* error */++3:+ jmp 2f+1:++ /* EBX=0 */++ cmpl $0xffffffff, ABS(install_partition)+ je 1f # --install-partition is not specified++ /* should not specify --install-partition with options for MBR. */+ cmpl $1, ABS(backup_mbr)+ movl $ABS(msg_option_backup_mbr_with_partition), %ecx+ jnz 4f /* error */++ cmpl $0, ABS(mbr_floppy)+ movl $ABS(msg_option_mbr_floppy_with_partition), %ecx+ jnz 4f /* error */+ + cmpl $0, ABS(mbr_osbr)+ movl $ABS(msg_option_mbr_osbr_with_partition), %ecx+ jnz 4f /* error */+ + cmpl $0, ABS(boot_prevmbr)+ movl $ABS(msg_option_boot_prevmbr_with_partition), %ecx+ jnz 4f /* error */+ + cmpl $0xff, ABS(preferred_drive)+ movl $ABS(msg_option_preferred_drive_with_partition), %ecx+ jnz 4f /* error */++ cmpl $0xff, ABS(preferred_partition)+ movl $ABS(msg_option_preferred_partition_with_partition), %ecx+ jnz 4f /* error */++ cmpl $0xffffff05, ABS(time_out)+ movl $ABS(msg_option_time_out_with_partition), %ecx+ jnz 4f /* error */++ cmpl $0xffff3920, ABS(hot_key)+ movl $ABS(msg_option_hot_key_with_partition), %ecx+ jnz 4f /* error */++ cmpl $0xffffff3f, ABS(sectors_per_track)+ movl $ABS(msg_option_sectors_per_track_with_partition), %ecx+ jnz 4f /* error */++ cmpl $0xffff00ff, ABS(heads)+ movl $ABS(msg_option_heads_with_partition), %ecx+ jnz 4f /* error */++ cmpl $0xffffffff, ABS(start_sector)+ movl $ABS(msg_option_start_sector_with_partition), %ecx+ jnz 4f /* error */++ cmpl $0, ABS(total_sectors)+ movl $ABS(msg_option_total_sectors_with_partition), %ecx+ jnz 4f /* error */++ jmp 2f+1:++ /* EBX=0 */++ /* this is an MBR device. Should not specify floppy-specific options. */++ testl $1, ABS(boot_prevmbr) /* --boot-prevmbr-first specified? */+ jnz 2f /* Yes, specified. Continue */+ /* No, not specified. */+ /* Should not specify --time-out without --boot-prevmbr-first. */+ cmpl $0xffffff05, ABS(time_out)+ movl $ABS(msg_option_time_out_without_prevmbr), %ecx+ jne 4f /* error */++ /* Should not specify --hot-key without --boot-prevmbr-first. */+ cmpl $0xffff3920, ABS(hot_key)+ movl $ABS(msg_option_hot_key_without_prevmbr), %ecx+ jne 4f /* error */++2:++ /* EBX=0, EDI points to the pathname of the file. */++//----------------------------------------------------------------------------+ movl %edi, %ebx # restore EBX from EDI+ + /* EBX=EDI points to the pathname of the file. */++#ifdef __DOS_16++ xorl %eax, %eax+ //movl %ebx, %edi /* EBX points to the pathname of the file. */+ movl $0xfe, %ebx+ call 7f /* parse_number */+ jc 2f /* invalid number */+ /* EBX holds the bios drive number */+ movl %ebx, ABS(bios_drive_number)+ jmp 1f+2:+ //AH = 3Dh //OPEN EXISTING FILE+ //AL = access and sharing modes (see #01402)+ //DS:DX -> ASCIZ filename+ //CL = attribute mask of files to look for (server call only)++ //Return:+ //CF clear if successful AX = file handle+ //CF set on error AX = error code (01h,02h,03h,04h,05h,0Ch,56h)++ movzbl ABS(read_only), %eax+ movb $0x3d, %ah // open file for read/write+ movl %edi, %edx // DS:DX points to ASCIZ filename+ int $0x21+ jnc 1f+ negl %eax /* EAX < 0 */+1:+#else++ /* int open(const char *pathname, int flags, mode_t mode) */++ movl $5, %eax # sys_open+ movzbl ABS(read_only), %ecx # O_RDWR = 02+ int $0x80+#endif+ xorl %ebx, %ebx # invalid file descriptor for CLOSE below+ movl $ABS(msg_open_file_rw), %ecx+ cmpw $2, ABS(read_only)+ je 1f+ movl $ABS(msg_open_file_ro), %ecx+1:+ testl %eax, %eax+ js 4f /* error */++//----------------------------------------------------------------------------+ /* open file succeeded */++ pushl %eax # file descriptor, or 0 if specified BIOS drive+ movl %eax, %ebx++ /* EBX and the stack holds the file descriptor number or 0 */+ +#ifdef __DOS_16++ xorl %eax, %eax+ cmpl $0xff, ABS(bios_drive_number)+ je 1f+ movw $0x204, %ax # read 4 sectors of the MBR+ movw $ABS(mbr_63_sectors), %bx+ movw $1, %cx+ movw ABS(bios_drive_number), %dx+ int $0x13+ jmp 2f+1:+ //READ FROM FILE OR DEVICE++ //AH = 3Fh+ //BX = file handle+ //CX = number of bytes to read+ //DS:DX -> buffer for data++ //Return:+ //CF clear if successful AX = number of bytes actually read (0 if at EOF before call)+ //CF set on error AX = error code (05h,06h) + movl $0x3f00, %eax+ movl $(63*512), %ecx+ movl $ABS(mbr_63_sectors), %edx+ int $0x21+2:+ jnc 1f+ negl %eax+1:+#else+ /* ssize_t read(int fd, void *buf, size_t count) */++ movl $3, %eax # sys_read+ movl $ABS(mbr_63_sectors), %ecx+ movl $(63*512), %edx # read 63 sectors+ int $0x80+#endif++ popl %ebx # file descriptor, or 0 if specified BIOS drive+ testl %eax, %eax+ movl $ABS(msg_read_file), %ecx+ js 4f /* error */++//----------------------------------------------------------------------------++ /* rewind the file for write! important! */++ pushl %ebx # file descriptor, or 0 if specified BIOS drive++#ifdef __DOS_16++ xorl %eax, %eax+ cmpl $0xff, ABS(bios_drive_number)+ jne 1f+ //LSEEK - SET CURRENT FILE POSITION++ //AH = 42h+ //AL = origin of move+ // 00h start of file+ // 01h current file position+ // 02h end of file+ //BX = file handle+ //CX:DX = (signed) offset from origin of new file position++ //Return:+ //CF clear if successful DX:AX = new file position in bytes from start of file+ //CF set on error AX = error code (01h,06h) + movl $0x4200, %eax+ movl $0, %ecx+ movl $0, %edx+ int $0x21+ jnc 1f+ negl %eax+1:+#else+ /* off_t lseek(int fildes, off_t offset, int whence) */++ movl $19, %eax # sys_lseek+ movl $0, %ecx+ movl $0, %edx # SEEK_SET = 0+ int $0x80+#endif++ popl %ebx # file descriptor, or 0 if specified BIOS drive+ testl %eax, %eax+ movl $ABS(msg_lseek_file), %ecx+ js 4f /* error */++//----------------------------------------------------------------------------+ /* remember EBX holds file descriptor number, and don't touch it */++ /* check if the partition table is valid. */++ movl $ABS(mbr_63_sectors), %esi+ cmpw $0xAA55, 0x1fe(iSI)+ movl $ABS(msg_boot_signature_mbr), %ecx+ //jne 4f /* error */+ clc+ jne 2f++ call 9f /* probe_geometry */+ jnc 1f++2:++ /* should be floppy since no partition table or no boot signature. */++ /* CF=0 means no boot signature, CF=1 means no partition table. */++ jnc 2f++ movl $ABS(msg_invalid_partition_table), %ecx+2:+ cmpl $0xffffffff, ABS(floppy) /* Is --floppy specified? */+ je 4f /* error */+ + /* Yes, --floppy is specified */++ /* ESI points to ABS(mbr_63_sectors) */+ call 5f /* floppy routine */+ movl $0, %ecx+ jc 4f /* error */+ + jmp 2f /* write file */+1:++//----------------------------------------------------------------------------+ /* the image type is MBR. So, should not specify --floppy */++ cmpl $0xffffffff, ABS(floppy)+ movl $ABS(msg_floppy_partition_table), %ecx+ jne 4f /* error */+ + cmpl $0xffffff3f, ABS(sectors_per_track)+ movl $ABS(msg_option_sectors_per_track_for_mbr), %ecx+ jnz 4f /* error */++ cmpl $0xffff00ff, ABS(heads)+ movl $ABS(msg_option_heads_for_mbr), %ecx+ jnz 4f /* error */++ cmpl $0xffffffff, ABS(start_sector)+ movl $ABS(msg_option_start_sector_for_mbr), %ecx+ jnz 4f /* error */++ cmpl $0, ABS(total_sectors)+ movl $ABS(msg_option_total_sectors_for_mbr), %ecx+ jnz 4f /* error */++ cmpl $0xffffffff, ABS(lba)+ movl $ABS(msg_option_lba_for_mbr), %ecx+ jnz 4f /* error */++ cmpl $0xfffffff7, ABS(fstypes)+ movl $ABS(msg_option_fstypes_for_mbr), %ecx+ jnz 4f /* error */++ cmpl $((pre_stage2_start - _start1) / 512), ABS(probed_sectors_per_track)+ movl $ABS(msg_sectors_per_track), %ecx+ jb 4f /* error */++ cmpl $0xffffffff, ABS(install_partition)+ movl $ABS(msg_option_install_partition_not_implemented), %ecx+ je 1f+ jmp 4f /* error */+ /* EBX holds the file descriptor number or 0 if it is BIOS drive */+ /* move partition table forward to the beginning of the 17th sector */+ movl $ABS(mbr_63_sectors + 0x01be), %esi+ movl $ABS(mbr_63_sectors + 0x2000), %edi+ movl $0x10, %ecx # 0x10 dwords = 0x40 bytes++ cld+ repz movsl++ /* initialize the current_partition number */+ movzbl ABS(install_partition), %eax+ movl %eax, ABS(current_partition)++3:+ /* load the next partition and modify the boot record */+ call 0f /* partition */+ jc 3f /* done */+ call 2f /* write to file */+ incl ABS(current_partition)+ movw ABS(install_partition), %ax+ addb %ah, %al /* Max partition number for install */+ cmpb %al, ABS(current_partition)+ jbe 3b+3:+ /* all partitions have been installed. */+ + xorl %eax, %eax # exit code = 0+ +#ifdef __DOS_16+ + movb $0x4c, %ah // EXIT - TERMINATE WITH RETURN CODE in AL+ int $0x21 // call DOS++#else+ xchgl %eax, %ebx # move exit code in EAX to EBX+ movl $1, %eax # sys_exit+ int $0x80+#endif+ + ret++1:+//----------------------------------------------------------------------------+ /* backup mbr */++ /* auto backup */+ cmpl $1, ABS(backup_mbr)+ jnz 1f++ /* check if the second sector consists of 512 dups of one byte */+ movb ABS(mbr_63_sectors + 0x200), %al+ movl $ABS(mbr_63_sectors + 0x200), %edi+ movl $0x200, %ecx++ cld+ repz scasb++ jz 1f # yes, enable backup++ movl $0, ABS(backup_mbr) # no, do not backup++1:+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -