diff --git a/ChangeLog b/ChangeLog index 52cb52ab5..72e2db43f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2000-08-27 OKUJI Yoshinori + + Preserve a magic number used by Windows NT in a MBR. Shit! + Reported by Khimenko Victor. + + * stage1/stage1.h (STAGE1_WINDOWS_NT_MAGIC): New macro. + * stage1/stage1.S (copy_buffer): Use pusha and popa, instead of + pushing/poping %cx and %si separately, to reduce the code size. + (nt_magic): New label. Set the offset to _start plus + STAGE1_WINDOWS_NT_MAGIC + (part_start): New label. + * stage2/builtins.c (install_func): If DEST_DRIVE is a hard + disk, copy the possible partition table and Windows NT magic to + STAGE1_BUFFER from OLD_SECT. + +2000-08-26 OKUJI Yoshinori + + * stage2/char_io.c (translate_keycode) [SUPPORT_SERIAL]: Don't + drain the input buffer, since that was irritating. + 2000-08-26 OKUJI Yoshinori Don't save/restore fragile registers unnecessarily. diff --git a/NEWS b/NEWS index c183b2d11..a4e8c990f 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,7 @@ New in 0.5.96 - XXXX-XX-XX: a new option `--enable-serial'. If it is specified, you can use two new commands, "serial" and "terminal" in the command-line and the menu. See the manual, for more details. +* Preserve the possible magic number used by Windows NT in a MBR. New in 0.5.95 - 2000-06-27: * NetBSD ELF kernel support is added. You have to specify the new option diff --git a/stage1/stage1.S b/stage1/stage1.S index 64b59a3af..b64097ead 100644 --- a/stage1/stage1.S +++ b/stage1/stage1.S @@ -344,9 +344,8 @@ copy_buffer: * We need to save %cx and %si because the startup code in * stage2 uses them without initializing them. */ - pushw %cx + pusha pushw %ds - pushw %si movw $0x100, %cx movw %bx, %ds @@ -358,9 +357,8 @@ copy_buffer: rep movsw - popw %si popw %ds - popw %cx + popa /* boot stage2 */ jmp *(stage2_address) @@ -420,12 +418,21 @@ message: jne 1b /* if not end of string, jmp to display */ ret + /* + * Windows NT breaks the compatibility by embedding a magic + * number here. + */ + +nt_magic: + . = _start + STAGE1_WINDOWS_NT_MAGIC + /* * This is where an MBR would go if on a hard disk. The code * here isn't even referenced unless we're on a floppy. Kinda * sneaky, huh? */ +part_start: . = _start + STAGE1_PARTSTART probe_values: diff --git a/stage1/stage1.h b/stage1/stage1.h index c99c0ab3b..25ddbbf9c 100644 --- a/stage1/stage1.h +++ b/stage1/stage1.h @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000 Free Software Foundation, Inc. * * 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 @@ -51,6 +51,9 @@ /* The offset of STAGE2_SEGMENT. */ #define STAGE1_STAGE2_SEGMENT 0x48 +/* The offset of a magic number used by Windows NT. */ +#define STAGE1_WINDOWS_NT_MAGIC 0x1b8 + /* The offset of the start of the partition table. */ #define STAGE1_PARTSTART 0x1be diff --git a/stage2/builtins.c b/stage2/builtins.c index 01f0f95d8..4661ae310 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -1625,10 +1625,10 @@ install_func (char *arg, int flags) BOOTSEC_BPB_LENGTH); /* If for a hard disk, copy the possible MBR/extended part table. */ - if ((dest_drive & 0x80) && current_partition == 0xFFFFFF) - grub_memmove (stage1_buffer + BOOTSEC_PART_OFFSET, - old_sect + BOOTSEC_PART_OFFSET, - BOOTSEC_PART_LENGTH); + if (dest_drive & 0x80) + grub_memmove (stage1_buffer + STAGE1_WINDOWS_NT_MAGIC, + old_sect + STAGE1_WINDOWS_NT_MAGIC, + STAGE1_PARTEND - STAGE1_WINDOWS_NT_MAGIC); /* Check for the version and the signature of Stage 1. */ if (*((short *)(stage1_buffer + STAGE1_VER_MAJ_OFFS)) != COMPAT_VERSION diff --git a/stage2/char_io.c b/stage2/char_io.c index c239daf1d..0cc3b8926 100644 --- a/stage2/char_io.c +++ b/stage2/char_io.c @@ -668,12 +668,6 @@ translate_keycode (int c) break; } } - - /* Drain the input buffer, because so-called VT100-compatible - terminals could send key codes which aren't handled in the - code above. */ - while (checkkey () != -1) - (void) getkey (); } } else diff --git a/stage2/serial.c b/stage2/serial.c index 99b4ddb01..3f5b74aba 100644 --- a/stage2/serial.c +++ b/stage2/serial.c @@ -45,6 +45,10 @@ static struct divisor divisor_tab[] = { 115200, 0x0001 } }; +/* The position of the cursor. */ +int serial_x; +int serial_y; + /* Read a byte from a port. */ static inline unsigned char diff --git a/stage2/serial.h b/stage2/serial.h index a77dbb9da..402bf99df 100644 --- a/stage2/serial.h +++ b/stage2/serial.h @@ -65,6 +65,13 @@ /* Turn on DTR, RTS, and OUT2. */ #define UART_ENABLE_MODEM 0x0B + +/* Variable prototypes. */ + +/* In the serial terminal, trace the cursor in GRUB itself. */ +extern int serial_x; +extern int serial_y; + /* Function prototypes. */ diff --git a/stage2/stage2.c b/stage2/stage2.c index 678f3e624..f35c22701 100644 --- a/stage2/stage2.c +++ b/stage2/stage2.c @@ -122,9 +122,9 @@ print_border (int y, int size) #ifndef GRUB_UTIL /* Color the menu. The menu is 75 * 14 characters. */ -#ifdef SUPPORT_SERIAL +# ifdef SUPPORT_SERIAL if (terminal & TERMINAL_CONSOLE) -#endif +# endif { for (i = 0; i < 14; i++) {