?? grub-0.97-patch8-bioscdrom
字號(hào):
diff -Naur grub-0.97_scdrom/ChangeLog grub-0.97_bioscdrom/ChangeLog--- grub-0.97_scdrom/ChangeLog 2006-10-24 12:28:52.000000000 +0800+++ grub-0.97_bioscdrom/ChangeLog 2006-10-24 12:28:54.000000000 +0800@@ -1,5 +1,9 @@ 2005-05-11 + From Tinybit <tinybit@163.net>:+ BIOS CDROM routine support.+ Currently only works on some ASUS motherboards.+ From Gandalf <f22_storm@163.com>: ATAPI CDROM support(experimental) diff -Naur grub-0.97_scdrom/grub/asmstub.c grub-0.97_bioscdrom/grub/asmstub.c--- grub-0.97_scdrom/grub/asmstub.c 2006-10-24 12:28:52.000000000 +0800+++ grub-0.97_bioscdrom/grub/asmstub.c 2006-10-24 12:28:54.000000000 +0800@@ -353,6 +353,11 @@ return 0; } +int+mount_cdrom (int mode)+{+ return 0;+} /* memory probe routines */ int get_memsize (int type)diff -Naur grub-0.97_scdrom/stage2/asm.S grub-0.97_bioscdrom/stage2/asm.S--- grub-0.97_scdrom/stage2/asm.S 2006-10-24 12:28:52.000000000 +0800+++ grub-0.97_bioscdrom/stage2/asm.S 2006-10-24 12:28:54.000000000 +0800@@ -5559,17 +5559,18 @@ */ ENTRY(chain_stage1)- /* no need to save anything, just use %esp */+ ///* no need to save anything, just use %esp */+ pushal // for CDROM boot failure /* store %ESI, presuming %ES is 0 */- movl 0xc(%esp), %esi+ movl 0x2c(%esp), %esi /* store new offset */- movl 0x8(%esp), %eax+ movl 0x28(%esp), %eax movl %eax, offset /* store new segment */- movw 0x4(%esp), %ax+ movw 0x24(%esp), %ax movw %ax, segment /* set up to pass boot drive */@@ -5581,12 +5582,21 @@ //sti /* it is not bad keeping interrupt off */ + /* The CDROM boot code might corrupt our stack, so we move to a safe place */+ movw $0x400, %sp // at the top of interrupt vector table, SS=0++ /* use lcall instead of ljmp to push the return address onto stack */ #ifdef ABSOLUTE_WITHOUT_ASTERISK- DATA32 ADDR32 ljmp (offset)+ DATA32 ADDR32 lcall (offset) #else- DATA32 ADDR32 ljmp *(offset)+ DATA32 ADDR32 lcall *(offset) #endif+ /* back to protected mode */+ DATA32 call EXT_C(real_to_prot) .code32+ popal+ ret+ #endif /* STAGE1_5 */ @@ -6044,6 +6054,296 @@ ret +/*+ * int mount_cdrom (int drive)+ *+ * Check if LBA is supported for DRIVE. If it is supported, then return+ * the major version of extensions, otherwise zero.+ */++ENTRY(mount_cdrom)+ pushl %ebp+ movl %esp, %ebp++ pushl %ebx++ /* drive */+ movl 0x8(%ebp), %edx+ /* enter real mode */+ call EXT_C(prot_to_real)++ .code16+ pushal+ pushw %ds+ pushw %es+ movw $0xF000, %ax+ movw %ax, %es+ xorw %di, %di+ movw %di, %ds+ cmpl $0xffffffff, %edx+ jne 2f+ /* unmount cdrom */+ movl ABS(award_orig), %ebx+ testl %ebx, %ebx+ jz 8f // not yet mounted, do nothing+ decb 0x475+ jmp 5f+2:+ movl ABS(award_orig), %ebx+ testl %ebx, %ebx+ jz 2f+ // already mounted, do nothing+ popw %es+ popw %ds+ popal+ xorl %ebx, %ebx+ incw %bx // show error+ jmp 7f+2:+ movl 0x4c, %eax // int13 vector+ movl %eax, ABS(award_orig)+ movl 0x4c1, %eax+ movl %eax, ABS(award_orig + 4)+ movl 0x4c5, %eax+ movl %eax, ABS(award_orig + 8)+ movb $0x9a, %al // lcall+ movw $0xffff, %cx // search the whole 64K ROM+#if 0+ movw $0x0201, %ax // 0xb8 0x01 0x02+ movw $0x7c00, %bx // 0xbb 0x00 0x7c+ movw $0x0006, %cx // 0xb9 0x06 0x00+ movw $0x0180, %dx // 0xba 0x80 0x01+ pushfw // 0x9c+ .byte 0x9a //lcall $0xf000, $0xba24+#endif+ cld+3:+ repnz scasb+ testw %cx, %cx //jcxz 6f // failed AWARD+ jz 6f+ cmpb $0x9c, %es:-2(%di) // pushfw+ jnz 3b+ cmpl $0x0180ba00, %es:-6(%di)+ jnz 3b+ cmpl $0x06b97c00, %es:-10(%di)+ jnz 3b+ cmpl $0xbb0201b8, %es:-14(%di)+ jnz 3b+ movl %es:(%di), %eax+ movl %eax, 0x4c+ movl $0x000c, %edi+4:+ decw %di+ cmpw $8, %di+ jb 5f+ movl %edi, 0x4c1+ movl $0xfbf7f300, 0x4c5+ movb $8, %ah+ movb $0x80, %dl+ int $0x13+ jc 4b+ cmpb $0, %ah+ jnz 4b+ cmpb $0xf2, %dh+ jnz 4b+ cmpw $0xfaf7, %cx+ jnz 4b+ /* change CHS, and try int13/AH=8 again */+ movl %edi, 0x4c1+ movl $0xffffff00, 0x4c5+ movb $8, %ah+ movb $0x80, %dl+ int $0x13+ jc 4b+ cmpb $0, %ah+ jnz 4b+ cmpb $0xfe, %dh+ jnz 4b+ cmpw $0xfeff, %cx+ jnz 4b+ pushw %es+ movw $SCRATCHSEG, %ax+ movw %ax, %es+ movw $0x201, %ax+ movw $0, %bx+ movw $1, %cx+ movw $0x80, %dx+ int $0x13+ popw %es+ jc 4b+ cmpb $0, %ah+ jnz 4b+ incb 0x475+8:+ popw %es+ popw %ds+ popal+ xorl %ebx, %ebx+ /* we've got the CDROM sector read function */+ cmpl $8, %edx /* boot cd? */+ jb 7f /* no, return to GRUB */+ + /* try to boot the cd, and, on failure, return here successfully */+ pushal+ pushw %ds+ pushw %es+ movw $0xF000, %ax+ movw %ax, %es+ xorw %di, %di+ movw %di, %ds+ movb $0xE8, %al // call+ movw $0xffff, %cx // search the whole 64K ROM+ cld+9:+ repnz scasb+ testw %cx, %cx //jcxz 6f // failed AWARD+ jz 5f // cannot boot cd+ cmpl $0xE8148A2E, %es:-15(%di) //mov dl,cs:[si]; call+ jnz 9b+ cmpw $0x830F, %es:-9(%di) //jnc+ jnz 9b+ cmpl $0x01548A2E, %es:-5(%di) //mov dl,cs:[si+01]+ jnz 9b+ cmpw $0x830F, %es:2(%di) //jnc+ jnz 9b+ cmpl $0x02548A2E, %es:6(%di) //mov dl,cs:[si+02]+ jnz 9b+ cmpb $0xE8, %es:10(%di) //call+ jnz 9b+ movw %es:-11(%di), %si+ movw %es:(%di), %bx+ movw %es:11(%di), %dx+ addw %di, %si+ subw $9, %si+ addw %di, %bx+ addw $2, %bx+ addw %di, %dx+ addw $13, %dx+ cmpw %si, %bx+ jnz 9b+ cmpw %dx, %bx+ jnz 9b++ /* SI=BX=DX=CDROM_BOOT_ENTRY_IN_ROM */++ xorw %di, %di+ movb $0xCB, %al // retf+ movw $0xffff, %cx // search the whole 64K ROM+ cld+ repnz scasb+ testw %cx, %cx //jcxz 6f // failed AWARD+ jz 5f // cannot boot cd++ /* restore original int13 vector */+ movl ABS(award_orig), %eax+ movl %eax, 0x4c // int13 vector+ //movl ABS(award_orig + 4), %eax+ //movl %eax, 0x4c1+ //movl ABS(award_orig + 8), %eax+ //movl %eax, 0x4c5++ decw %di // points to RETF instruction in ROM++ movb $0xBB, 0x7C00 // mov bx, ...+ movw $0x7C00, 0x7C01 // 7C00+ movb $0xB9, 0x7C03 // mov cx, ...+ movw $1, 0x7C04 // 0001+ movb $0xBA, 0x7C06 // mov dx, ...+ movw $0x80, 0x7C07 // 0080++ movb $0x68, 0x7c09 // push immediate word+ movw %di, 0x7c0a+ movb $0xEA, 0x7c0c // ljmp+ movw %si, 0x7c0d+ movw $0xF000, 0x7c0f++ popw %es+ popw %ds+ popal+ xorl %ebx, %ebx+ jmp 7f++ //pushw %ds+ //pushw %es++ //xorw %ax, %ax+ //movw %ax, %ds+ //movw %ax, %es+ //movw $0x7c00, %bx+ //movw $1, %cx+ //movw $0x80, %dx+ + //pushw %cs+ //call dummy_boot_cd // simulate a far call+ + ///* return here on CDROM BOOT failure */+ //popw %es+ //popw %ds+5:+ movl ABS(award_orig), %eax+ movl %eax, 0x4c // int13 vector+ movl ABS(award_orig + 4), %eax+ movl %eax, 0x4c1+ movl ABS(award_orig + 8), %eax+ movl %eax, 0x4c5+6:+ xorl %eax, %eax+ movl %eax, ABS(award_orig)+ movl %eax, ABS(award_orig + 4)+ movl %eax, ABS(award_orig + 8)+ popw %es+ popw %ds+ popal+ movb $1, %bl+7:+ /* back to protected mode */+ DATA32 call EXT_C(real_to_prot)+ .code32++ movl %ebx, %eax /* return value in %eax */++ popl %ebx+ popl %ebp++ ret++#if 0+dummy_boot_cd:++ /* the stack is:+ *+ * CS ---------- this segment+ * IP ---------- the return address of the dummy_boot_cd function+ *+ * before the call:+ *+ * SI ---------- points to CDROM BOOT function in ROM+ * DI ---------- points to FAR RET instruction in ROM+ */++ /* before far jmp to F000:SI, set the return address of CDROM BOOT+ * function to be a FAR RET in ROM+ */++ cli+ movw %ax, %ss+ movw $0x400, %sp+ sti+ //ljmp $0xF000, $0xfff0+ int $0x19+ pushw %di+ pushw $0xF000+ pushw %si+ lret // simulate far jmp to F000:SI++ /* never get here */+#endif++award_orig:+ .long 0 // int13+ .long 0 // at 0x4c1+ .long 0 // at 0x4c5+ /* * int get_diskinfo_standard (int drive, unsigned long *cylinders, diff -Naur grub-0.97_scdrom/stage2/builtins.c grub-0.97_bioscdrom/stage2/builtins.c--- grub-0.97_scdrom/stage2/builtins.c 2006-10-24 12:28:53.000000000 +0800+++ grub-0.97_bioscdrom/stage2/builtins.c 2006-10-24 12:28:54.000000000 +0800@@ -583,7 +583,7 @@ /* if our terminal needed initialization, we should shut it down * before booting the kernel, but we want to save what it was so * we can come back if needed */- if (current_term->shutdown) + if (kernel_type != KERNEL_TYPE_NONE && current_term->shutdown) { (*current_term->shutdown)(); current_term = term_table; /* assumption: console is first */@@ -591,7 +591,8 @@ #ifdef SUPPORT_NETBOOT /* Shut down the networking. */- cleanup_net ();+ if (kernel_type != KERNEL_TYPE_NONE)+ cleanup_net (); #endif old_cursor = setcursor (1);@@ -912,6 +913,9 @@ } chain_stage1 (0, BOOTSEC_LOCATION, boot_part_addr); /* no return */+ /* yes, we might come here, e.g., on CDROM failure. */+ gateA20 (1);+ kernel_type = KERNEL_TYPE_NONE; break; case KERNEL_TYPE_MULTIBOOT:@@ -4615,6 +4619,70 @@ }; +/* bioscdrom */+static int+bioscdrom_func (char *arg, int flags)+{+ extern int mount_cdrom(int drive);+ int err;+ int cdrom;+ + if (grub_memcmp (arg, "--mount", 7) == 0)+ {+ err = mount_cdrom (cdrom=4);+ }+ else if (grub_memcmp (arg, "--unmount", 9) == 0)+ {+ err = mount_cdrom (cdrom=-1);+ }+ else if (grub_memcmp (arg, "--boot", 6) == 0)+ {+ err = mount_cdrom (cdrom=9);+ }+ else if (grub_memcmp (arg, "--chainloader", 13) == 0)+ {+ err = mount_cdrom (cdrom=8);+ }+ else+ {+ grub_printf ("status report: not implemented yet.\n");+ return 0;+ }+ + if (cdrom >= 8 && !err)+ {+ if (cdrom == 8)+ grub_printf ("Ready to boot CDROM. Enter 'boot', please.\n");+ kernel_type = KERNEL_TYPE_CHAINLOADER;+ if (cdrom != 8)+ boot_func (arg, flags);+ }++ if (err)+ if (cdrom == -1)+ grub_printf ("cdrom unmounted ok\n");+ else+ grub_printf ("Failed mount cdrom. Try unmount first if already mounted.\n");+ else+ if (cdrom == -1)+ grub_printf ("cdrom not yet mounted\n");+ else+ grub_printf ("cdrom mounted ok\n");+ return 0;+}++static struct builtin builtin_bioscdrom =+{+ "bioscdrom",+ bioscdrom_func,+ BUILTIN_CMDLINE | BUILTIN_HELP_LIST,+ "bioscdrom [--mount | --unmount | --boot | --chainloader]",+ "Try to access the BIOS cdrom routine to mount the cdrom(the option --mount)"+ " or to boot the cdrom(the option --boot). The --chainloader"+ " option is similar to --boot, but does not cause an immediate boot, and"+ " a further 'boot' command is expected."+};+ #ifndef GRUB_UTIL static unsigned long start_sector, sector_count; @@ -9405,6 +9473,7 @@ #ifdef SUPPORT_GRAPHICS &builtin_background, #endif+ &builtin_bioscdrom, &builtin_blocklist, #ifndef GRUB_UTIL &builtin_boot,
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -