diff --git a/ChangeLog b/ChangeLog index 80f6a7e53..62772d1ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,38 @@ +2000-08-21 OKUJI Yoshinori + + * configure.in (--enable-serial-speed-emulation): New option. + (SERIAL_SPEED_SIMULATION): New conditional. + * grub/Makefile.am (SERIAL_FLAGS): New variable. Set + -DSUPPORT_SERIAL=1 and -DSIMULATE_SLOWNESS_OF_SERIAL=1, if + SERIAL_SPEED_SIMULATION is defined, otherwise, set it to + only -DSUPPORT_SERIAL=1. + (AM_CFLAGS): Removed -DSUPPORT_SERIAL=1 and added + $(SERIAL_FLAGS). + * grub/asmstub.c [SIMULATE_SLOWNESS_OF_SERIAL] (serial_speed): + New variable. + (grub_setjmp): Removed. + (grub_longjmp): Likewise. + (serial_getkey) [SIMULATE_SLOWNESS_OF_SERIAL]: Wait for + 1000000 / (SERIAL_SPEED >> 3) microseconds using gettimeofday. + (serial_putchar) [SIMULATE_SLOWNESS_OF_SERIAL]: Likewise. + (serial_init) [SIMULATE_SLOWNESS_OF_SERIAL]: Set SERIAL_SPEED to + SPEED. + * stage2/builtins.c (serial_func) [SUPPORT_SERIAL]: Added + a new option, `--speed'. + (builtin_serial): Added a description about --speed. + (terminal_func): When get a key from a serial device, if GRUB is + in the command-line interface, call grub_longjmp with + RESTART_CMDLINE_ENV, instead of init_page. + * stage2/cmdline.c (restart_cmdline_env): New variable. + (enter_cmdline): Call grub_setjmp with RESTART_CMDLINE_ENV after + calling init_cmdline. + (run_script): Run BUILTIN->FUNC with BUILTIN_SCRIPT instead of + BUILTIN_CMDLINE. + * stage2/shared.h (BUILTIN_SCRIPT): New macro. + [GRUB_UTIL] (grub_setjmp): Defined as setjmp. + [GRUB_UTIL] (grub_longjmp): Defined as longjmp. + (restart_cmdline_env): Declared. + 2000-08-20 OKUJI Yoshinori * configure.in (--enable-serial): New option. Serial terminal diff --git a/configure b/configure index 7b8b223fd..cc7a5d85a 100644 --- a/configure +++ b/configure @@ -116,6 +116,9 @@ ac_help="$ac_help --enable-diskless enable diskless support" ac_help="$ac_help --enable-serial enable serial terminal support" +ac_help="$ac_help + --enable-serial-speed-simulation + simulate the slowness of a serial device" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -657,7 +660,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:661: checking for a BSD compatible install" >&5 +echo "configure:664: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -710,7 +713,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:714: checking whether build environment is sane" >&5 +echo "configure:717: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -782,7 +785,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:786: checking for $ac_word" >&5 +echo "configure:789: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -812,7 +815,7 @@ test -n "$AWK" && break done echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:816: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:819: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -938,7 +941,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:942: checking host system type" >&5 +echo "configure:945: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -972,7 +975,7 @@ esac # echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:976: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:979: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -998,7 +1001,7 @@ if test "x$enable_maintainer_mode" = xyes; then # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1002: checking for $ac_word" >&5 +echo "configure:1005: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1045,7 +1048,7 @@ fi # echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:1049: checking build system type" >&5 +echo "configure:1052: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -1071,7 +1074,7 @@ fi # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1075: checking for $ac_word" >&5 +echo "configure:1078: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1103,7 +1106,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1107: checking for $ac_word" >&5 +echo "configure:1110: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1133,7 +1136,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1137: checking for $ac_word" >&5 +echo "configure:1140: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1184,7 +1187,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1188: checking for $ac_word" >&5 +echo "configure:1191: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1216,7 +1219,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1220: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1223: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1227,12 +1230,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1231 "configure" +#line 1234 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1258,12 +1261,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1262: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1265: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1267: checking whether we are using GNU C" >&5 +echo "configure:1270: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1272,7 +1275,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1276: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1279: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1291,7 +1294,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1295: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1298: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1324,7 +1327,7 @@ fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1328: checking how to run the C preprocessor" >&5 +echo "configure:1331: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1339,13 +1342,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1349: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1352: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1356,13 +1359,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1366: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1369: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1373,13 +1376,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1383: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1386: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1412,7 +1415,7 @@ echo "$ac_t""$CPP" 1>&6 depcc="$CC" depcpp="$CPP" echo $ac_n "checking dependency style of $depcc""... $ac_c" 1>&6 -echo "configure:1416: checking dependency style of $depcc" >&5 +echo "configure:1419: checking dependency style of $depcc" >&5 if eval "test \"`echo '$''{'am_cv_CC_dependencies_compiler_type'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1468,7 +1471,7 @@ if test "x$with_binutils" != x; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1472: checking for $ac_word" >&5 +echo "configure:1475: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1505,7 +1508,7 @@ else # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1509: checking for $ac_word" >&5 +echo "configure:1512: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1545,7 +1548,7 @@ if test "x$ac_cv_prog_gcc" = xyes; then STAGE1_CFLAGS="-O2" GRUB_CFLAGS="-O2" echo $ac_n "checking whether optimization for size works""... $ac_c" 1>&6 -echo "configure:1549: checking whether optimization for size works" >&5 +echo "configure:1552: checking whether optimization for size works" >&5 if eval "test \"`echo '$''{'size_flag'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1553,14 +1556,14 @@ else saved_CFLAGS=$CFLAGS CFLAGS="-Os -g" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* size_flag=yes else @@ -1595,7 +1598,7 @@ if test "x$with_binutils" != x; then # Extract the first word of "objcopy", so it can be a program name with args. set dummy objcopy; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1599: checking for $ac_word" >&5 +echo "configure:1602: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_OBJCOPY'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1631,7 +1634,7 @@ else # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args. set dummy ${ac_tool_prefix}objcopy; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1635: checking for $ac_word" >&5 +echo "configure:1638: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1665,7 +1668,7 @@ fi # Defined in acinclude.m4. echo $ac_n "checking if C symbols get an underscore after compilation""... $ac_c" 1>&6 -echo "configure:1669: checking if C symbols get an underscore after compilation" >&5 +echo "configure:1672: checking if C symbols get an underscore after compilation" >&5 if eval "test \"`echo '$''{'grub_cv_asm_uscore'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1678,7 +1681,7 @@ func (int *list) } EOF -if { ac_try='${CC-cc} ${CFLAGS} -S conftest.c'; { (eval echo configure:1682: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then +if { ac_try='${CC-cc} ${CFLAGS} -S conftest.c'; { (eval echo configure:1685: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then true else { echo "configure: error: ${CC-cc} failed to produce assembly code" 1>&2; exit 1; } @@ -1704,7 +1707,7 @@ fi echo "$ac_t""$grub_cv_asm_uscore" 1>&6 echo $ac_n "checking whether ${OBJCOPY} works for absolute addresses""... $ac_c" 1>&6 -echo "configure:1708: checking whether ${OBJCOPY} works for absolute addresses" >&5 +echo "configure:1711: checking whether ${OBJCOPY} works for absolute addresses" >&5 if eval "test \"`echo '$''{'grub_cv_prog_objcopy_absolute'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1716,21 +1719,21 @@ cmain (void) } EOF -if { (eval echo configure:1720: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then : +if { (eval echo configure:1723: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then : else { echo "configure: error: ${CC-cc} cannot compile C source code" 1>&2; exit 1; } fi grub_cv_prog_objcopy_absolute=yes for link_addr in 2000 8000 7C00; do - if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec'; { (eval echo configure:1726: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : + if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec'; { (eval echo configure:1729: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : else { echo "configure: error: ${CC-cc} cannot link at address $link_addr" 1>&2; exit 1; } fi - if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo configure:1730: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : + if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo configure:1733: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : else { echo "configure: error: ${OBJCOPY-objcopy} cannot create binary files" 1>&2; exit 1; } fi - if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo configure:1734: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo configure:1737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then mv -f conftest conftest.old else grub_cv_prog_objcopy_absolute=no @@ -1747,7 +1750,7 @@ fi echo $ac_n "checking whether addr32 must be in the same line as the instruction""... $ac_c" 1>&6 -echo "configure:1751: checking whether addr32 must be in the same line as the instruction" >&5 +echo "configure:1754: checking whether addr32 must be in the same line as the instruction" >&5 if eval "test \"`echo '$''{'grub_cv_asm_prefix_requirement'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1756,7 +1759,7 @@ else l1: addr32 movb %al, l1 EOF -if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1760: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then +if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1763: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then grub_cv_asm_prefix_requirement=yes else grub_cv_asm_prefix_requirement=no @@ -1788,7 +1791,7 @@ echo "$ac_t""$grub_cv_asm_prefix_requirement" 1>&6 echo $ac_n "checking for .code16 addr32 assembler support""... $ac_c" 1>&6 -echo "configure:1792: checking for .code16 addr32 assembler support" >&5 +echo "configure:1795: checking for .code16 addr32 assembler support" >&5 if eval "test \"`echo '$''{'grub_cv_asm_addr32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1803,7 +1806,7 @@ else sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s fi -if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1807: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then +if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1810: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then grub_cv_asm_addr32=yes else grub_cv_asm_addr32=no @@ -1820,7 +1823,7 @@ fi echo $ac_n "checking whether an absolute indirect call/jump must not be prefixed with an asterisk""... $ac_c" 1>&6 -echo "configure:1824: checking whether an absolute indirect call/jump must not be prefixed with an asterisk" >&5 +echo "configure:1827: checking whether an absolute indirect call/jump must not be prefixed with an asterisk" >&5 if eval "test \"`echo '$''{'grub_cv_asm_absolute_without_asterisk'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1831,7 +1834,7 @@ offset: .word 0 EOF -if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1835: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then +if { ac_try='${CC-cc} ${CFLAGS} -c conftest.s'; { (eval echo configure:1838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then grub_cv_asm_absolute_without_asterisk=no else grub_cv_asm_absolute_without_asterisk=yes @@ -1852,19 +1855,19 @@ echo "$ac_t""$grub_cv_asm_absolute_without_asterisk" 1>&6 echo $ac_n "checking if start is defined by the compiler""... $ac_c" 1>&6 -echo "configure:1856: checking if start is defined by the compiler" >&5 +echo "configure:1859: checking if start is defined by the compiler" >&5 if eval "test \"`echo '$''{'grub_cv_check_start_symbol'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1871: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* grub_cv_check_start_symbol=yes else @@ -1888,19 +1891,19 @@ echo "$ac_t""$grub_cv_check_start_symbol" 1>&6 echo $ac_n "checking if _start is defined by the compiler""... $ac_c" 1>&6 -echo "configure:1892: checking if _start is defined by the compiler" >&5 +echo "configure:1895: checking if _start is defined by the compiler" >&5 if eval "test \"`echo '$''{'grub_cv_check_uscore_start_symbol'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1907: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* grub_cv_check_uscore_start_symbol=yes else @@ -1929,19 +1932,19 @@ fi echo $ac_n "checking if __bss_start is defined by the compiler""... $ac_c" 1>&6 -echo "configure:1933: checking if __bss_start is defined by the compiler" >&5 +echo "configure:1936: checking if __bss_start is defined by the compiler" >&5 if eval "test \"`echo '$''{'grub_cv_check_uscore_uscore_bss_start_symbol'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1948: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* grub_cv_check_uscore_uscore_bss_start_symbol=yes else @@ -1965,19 +1968,19 @@ echo "$ac_t""$grub_cv_check_uscore_uscore_bss_start_symbol" 1>&6 echo $ac_n "checking if _edata is defined by the compiler""... $ac_c" 1>&6 -echo "configure:1969: checking if _edata is defined by the compiler" >&5 +echo "configure:1972: checking if _edata is defined by the compiler" >&5 if eval "test \"`echo '$''{'grub_cv_check_uscore_edata_symbol'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* grub_cv_check_uscore_edata_symbol=yes else @@ -2001,19 +2004,19 @@ echo "$ac_t""$grub_cv_check_uscore_edata_symbol" 1>&6 echo $ac_n "checking if edata is defined by the compiler""... $ac_c" 1>&6 -echo "configure:2005: checking if edata is defined by the compiler" >&5 +echo "configure:2008: checking if edata is defined by the compiler" >&5 if eval "test \"`echo '$''{'grub_cv_check_edata_symbol'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2020: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* grub_cv_check_edata_symbol=yes else @@ -2043,19 +2046,19 @@ fi echo $ac_n "checking if end is defined by the compiler""... $ac_c" 1>&6 -echo "configure:2047: checking if end is defined by the compiler" >&5 +echo "configure:2050: checking if end is defined by the compiler" >&5 if eval "test \"`echo '$''{'grub_cv_check_end_symbol'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2062: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* grub_cv_check_end_symbol=yes else @@ -2079,19 +2082,19 @@ echo "$ac_t""$grub_cv_check_end_symbol" 1>&6 echo $ac_n "checking if _end is defined by the compiler""... $ac_c" 1>&6 -echo "configure:2083: checking if _end is defined by the compiler" >&5 +echo "configure:2086: checking if _end is defined by the compiler" >&5 if eval "test \"`echo '$''{'grub_cv_check_uscore_end_symbol'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2098: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* grub_cv_check_uscore_end_symbol=yes else @@ -2129,7 +2132,7 @@ fi # Get the filename or the whole disk and open it. # Known to work on NetBSD. echo $ac_n "checking for opendisk in -lutil""... $ac_c" 1>&6 -echo "configure:2133: checking for opendisk in -lutil" >&5 +echo "configure:2136: checking for opendisk in -lutil" >&5 ac_lib_var=`echo util'_'opendisk | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2137,7 +2140,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lutil $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2155: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2176,7 +2179,7 @@ fi # Unless the user specify --without-curses, check for curses. if test "x$with_curses" != "xno"; then echo $ac_n "checking for wgetch in -lncurses""... $ac_c" 1>&6 -echo "configure:2180: checking for wgetch in -lncurses" >&5 +echo "configure:2183: checking for wgetch in -lncurses" >&5 ac_lib_var=`echo ncurses'_'wgetch | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2184,7 +2187,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2218,7 +2221,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for wgetch in -lcurses""... $ac_c" 1>&6 -echo "configure:2222: checking for wgetch in -lcurses" >&5 +echo "configure:2225: checking for wgetch in -lcurses" >&5 ac_lib_var=`echo curses'_'wgetch | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2226,7 +2229,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2244: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2272,17 +2275,17 @@ for ac_hdr in string.h strings.h ncurses/curses.h ncurses.h curses.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2276: checking for $ac_hdr" >&5 +echo "configure:2279: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2286: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2289: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2813,6 +2816,22 @@ else SERIAL_SUPPORT_FALSE= fi +# Check whether --enable-serial-speed-simulation or --disable-serial-speed-simulation was given. +if test "${enable_serial_speed_simulation+set}" = set; then + enableval="$enable_serial_speed_simulation" + : +fi + + + +if test "x$enable_serial_speed_simulation" = xyes; then + SERIAL_SPEED_SIMULATION_TRUE= + SERIAL_SPEED_SIMULATION_FALSE='#' +else + SERIAL_SPEED_SIMULATION_TRUE='#' + SERIAL_SPEED_SIMULATION_FALSE= +fi + # Sanity check. if test "x$enable_diskless" = xyes; then if test "x$NET_CFLAGS" = x; then @@ -3007,6 +3026,8 @@ s%@DISKLESS_SUPPORT_TRUE@%$DISKLESS_SUPPORT_TRUE%g s%@DISKLESS_SUPPORT_FALSE@%$DISKLESS_SUPPORT_FALSE%g s%@SERIAL_SUPPORT_TRUE@%$SERIAL_SUPPORT_TRUE%g s%@SERIAL_SUPPORT_FALSE@%$SERIAL_SUPPORT_FALSE%g +s%@SERIAL_SPEED_SIMULATION_TRUE@%$SERIAL_SPEED_SIMULATION_TRUE%g +s%@SERIAL_SPEED_SIMULATION_FALSE@%$SERIAL_SPEED_SIMULATION_FALSE%g s%@FSYS_CFLAGS@%$FSYS_CFLAGS%g s%@NET_CFLAGS@%$NET_CFLAGS%g s%@NET_EXTRAFLAGS@%$NET_EXTRAFLAGS%g diff --git a/configure.in b/configure.in index 6d7c0cf4a..55225fa68 100644 --- a/configure.in +++ b/configure.in @@ -484,6 +484,13 @@ AC_ARG_ENABLE(serial, [ --enable-serial enable serial terminal support]) AM_CONDITIONAL(SERIAL_SUPPORT, test "x$enable_serial" = xyes) +dnl Simulation of the slowness of a serial device. +AC_ARG_ENABLE(serial-speed-simulation, + [ --enable-serial-speed-simulation + simulate the slowness of a serial device]) +AM_CONDITIONAL(SERIAL_SPEED_SIMULATION, + test "x$enable_serial_speed_simulation" = xyes) + # Sanity check. if test "x$enable_diskless" = xyes; then if test "x$NET_CFLAGS" = x; then diff --git a/grub/Makefile.am b/grub/Makefile.am index 53bd5e372..e985577ad 100644 --- a/grub/Makefile.am +++ b/grub/Makefile.am @@ -1,7 +1,13 @@ sbin_PROGRAMS = grub +if SERIAL_SPEED_SIMULATION +SERIAL_FLAGS = -DSUPPORT_SERIAL=1 -DSIMULATE_SLOWNESS_OF_SERIAL=1 +else +SERIAL_FLAGS = -DSUPPORT_SERIAL=1 +endif + AM_CFLAGS = $(GRUB_CFLAGS) -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 \ - -DFSYS_FFS=1 -DFSYS_MINIX=1 -DSUPPORT_SERIAL=1 \ + -DFSYS_FFS=1 -DFSYS_MINIX=1 $(SERIAL_FLAGS) \ -fwritable-strings -I$(top_srcdir)/stage2 \ -I$(top_srcdir)/stage1 -I$(top_srcdir)/lib diff --git a/grub/Makefile.in b/grub/Makefile.in index 3b06c752d..94a3f5e38 100644 --- a/grub/Makefile.in +++ b/grub/Makefile.in @@ -88,9 +88,11 @@ install_sh = @install_sh@ sbin_PROGRAMS = grub +@SERIAL_SPEED_SIMULATION_TRUE@SERIAL_FLAGS = @SERIAL_SPEED_SIMULATION_TRUE@-DSUPPORT_SERIAL=1 -DSIMULATE_SLOWNESS_OF_SERIAL=1 +@SERIAL_SPEED_SIMULATION_FALSE@SERIAL_FLAGS = @SERIAL_SPEED_SIMULATION_FALSE@-DSUPPORT_SERIAL=1 AM_CFLAGS = $(GRUB_CFLAGS) -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 \ - -DFSYS_FFS=1 -DFSYS_MINIX=1 -DSUPPORT_SERIAL=1 \ + -DFSYS_FFS=1 -DFSYS_MINIX=1 $(SERIAL_FLAGS) \ -fwritable-strings -I$(top_srcdir)/stage2 \ -I$(top_srcdir)/stage1 -I$(top_srcdir)/lib diff --git a/grub/asmstub.c b/grub/asmstub.c index fa00caa4d..79672fc3f 100644 --- a/grub/asmstub.c +++ b/grub/asmstub.c @@ -89,6 +89,11 @@ static int serial_fd = -1; /* The file name of a serial device. */ static char *serial_device = 0; +#ifdef SIMULATE_SLOWNESS_OF_SERIAL +/* The speed of a serial device. */ +static unsigned int serial_speed; +#endif /* SIMULATE_SLOWNESS_OF_SERIAL */ + /* The main entry point into this mess. */ int grub_stage2 (void) @@ -463,18 +468,6 @@ console_gotoxy (int x, int y) #endif } -int -grub_setjmp (grub_jmp_buf env) -{ - return setjmp (env); -} - -void -grub_longjmp (grub_jmp_buf env, int val) -{ - longjmp (env, val); -} - /* displays an ASCII character. IBM displays will translate some characters to special graphical ones */ void @@ -824,10 +817,30 @@ int serial_getkey (void) { char c; +#ifdef SIMULATE_SLOWNESS_OF_SERIAL + struct timeval otv, tv; + gettimeofday (&otv, 0); +#endif /* SIMULATE_SLOWNESS_OF_SERIAL */ + if (nread (serial_fd, &c, 1) != 1) stop (); +#ifdef SIMULATE_SLOWNESS_OF_SERIAL + while (1) + { + long delta; + + gettimeofday (&tv, 0); + delta = tv.tv_usec - otv.tv_usec; + if (delta < 0) + delta += 1000000; + + if (delta >= 1000000 / (serial_speed >> 3)) + break; + } +#endif /* SIMULATE_SLOWNESS_OF_SERIAL */ + return c; } @@ -854,9 +867,29 @@ void serial_putchar (int c) { char ch = (char) c; +#ifdef SIMULATE_SLOWNESS_OF_SERIAL + struct timeval otv, tv; + + gettimeofday (&otv, 0); +#endif /* SIMULATE_SLOWNESS_OF_SERIAL */ if (nwrite (serial_fd, &ch, 1) != 1) stop (); + +#ifdef SIMULATE_SLOWNESS_OF_SERIAL + while (1) + { + long delta; + + gettimeofday (&tv, 0); + delta = tv.tv_usec - otv.tv_usec; + if (delta < 0) + delta += 1000000; + + if (delta >= 1000000 / (serial_speed >> 3)) + break; + } +#endif /* SIMULATE_SLOWNESS_OF_SERIAL */ } static speed_t @@ -978,6 +1011,10 @@ serial_init (unsigned short port, unsigned int speed, /* Set the parameters. */ if (tcsetattr (serial_fd, TCSANOW, &termios)) goto fail; + +#ifdef SIMULATE_SLOWNESS_OF_SERIAL + serial_speed = speed; +#endif /* SIMUATE_SLOWNESS_OF_SERIAL */ return 1; diff --git a/stage2/builtins.c b/stage2/builtins.c index 7b54aec32..09c5f785f 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -2672,6 +2672,16 @@ serial_func (char *arg, int flags) port = serial_get_port (unit); } + else if (grub_memcmp (arg, "--speed=", sizeof ("--speed=") - 1) == 0) + { + char *p = arg + sizeof ("--speed=") - 1; + int num; + + if (! safe_parse_maxint (&p, &num)) + return 1; + + port = (unsigned int) num; + } else if (grub_memcmp (arg, "--port=", sizeof ("--port=") - 1) == 0) { char *p = arg + sizeof ("--port=") - 1; @@ -2776,13 +2786,14 @@ static struct builtin builtin_serial = "serial", serial_func, BUILTIN_MENU | BUILTIN_CMDLINE, - "serial [--unit=UNIT] [--port=PORT] [--word=WORD] [--parity=PARITY] [--stop=STOP] [--device=DEV]", + "serial [--unit=UNIT] [--port=PORT] [--speed=SPEED] [--word=WORD] [--parity=PARITY] [--stop=STOP] [--device=DEV]", "Initialize a serial device. UNIT is a digit that specifies which serial" " device is used (e.g. 0 == COM1). If you need to specify the port number," - " set it by --port. WORD is the word length, PARITY is the type of parity," - " which is one of `no', `odd' and `even'. STOP is the length of stop bit(s)." - " The option --device can be used only in the grub shell, which specifies" - " the file name of a tty device. The default values are COM1, 8N1." + " set it by --port. SPEED is the DTE-DTE speed. WORD is the word length," + " PARITY is the type of parity, which is one of `no', `odd' and `even'." + " STOP is the length of stop bit(s). The option --device can be used only" + " in the grub shell, which specifies the file name of a tty device. The" + " default values are COM1, 9600, 8N1." }; @@ -3319,12 +3330,11 @@ terminal_func (char *arg, int flags) { terminal = TERMINAL_SERIAL; (void) getkey (); + + /* If the interface is currently the command-line, restart + it to repaint the screen. */ if (flags & BUILTIN_CMDLINE) - { - /* FIXME: It is better to restart enter_cmdline except - for init_cmdline. */ - init_page (); - } + grub_longjmp (restart_cmdline_env, 0); break; } diff --git a/stage2/cmdline.c b/stage2/cmdline.c index 7bb6b11d7..a6368a4c1 100644 --- a/stage2/cmdline.c +++ b/stage2/cmdline.c @@ -25,6 +25,8 @@ # include #endif +grub_jmp_buf restart_cmdline_env; + /* Find the next word from CMDLINE and return the pointer. If AFTER_EQUAL is non-zero, assume that the character `=' is treated as a space. Caution: this assumption is for backward compatibility. */ @@ -120,6 +122,7 @@ enter_cmdline (char *heap, int forever) { /* Initialize the data and print a message. */ init_cmdline (); + grub_setjmp (restart_cmdline_env); init_page (); #ifdef SUPPORT_DISKLESS print_network_configuration (); @@ -231,6 +234,6 @@ run_script (char *script, char *heap) /* Run BUILTIN->FUNC. */ arg = skip_to (1, heap); - (builtin->func) (arg, BUILTIN_CMDLINE); + (builtin->func) (arg, BUILTIN_SCRIPT); } } diff --git a/stage2/shared.h b/stage2/shared.h index ba714cf23..7e94178fe 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -699,6 +699,7 @@ void stop_floppy (void); #define BUILTIN_CMDLINE 0x1 /* Run in the command-line. */ #define BUILTIN_MENU 0x2 /* Run in the menu. */ #define BUILTIN_TITLE 0x4 /* Only for the command title. */ +#define BUILTIN_SCRIPT 0x8 /* Run in the script. */ /* The table for a builtin. */ struct builtin @@ -773,11 +774,18 @@ typedef unsigned long grub_jmp_buf[6]; # define grub_jmp_buf jmp_buf #endif +#ifdef GRUB_UTIL +# define grub_setjmp setjmp +# define grub_longjmp longjmp +#else /* ! GRUB_UTIL */ int grub_setjmp (grub_jmp_buf env); void grub_longjmp (grub_jmp_buf env, int val); +#endif /* ! GRUB_UTIL */ /* The environment for restarting Stage 2. */ extern grub_jmp_buf restart_env; +/* The environment for restarting the command-line interface. */ +extern grub_jmp_buf restart_cmdline_env; /* misc */ void init_page (void);