Subject: port-i386/14748: mbr_bootsel timeouts >30 mins are treated as no timeout
To: None <gnats-bugs@gnats.netbsd.org>
From: None <david.laight@btinternet.com>
List: netbsd-bugs
Date: 11/27/2001 06:58:14
>Number:         14748
>Category:       port-i386
>Synopsis:       mbr_bootsel timeouts >30 mins are treated as no timeout
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 27 06:59:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     David Laight
>Release:        1.5.2
>Organization:
>Environment:
>Description:
If you set the boot timeout to more than 1800 seconds using fdisk -B
then boot select code waits no time at all.

Tricky to get back if the default partition isn't a netBSD one.

One reason for specifying a long timeout is to simulate 'wait forever'.
>How-To-Repeat:

>Fix:
Change the mbr_bootsel code to do unsigned 16bit arithmetic.
eg change sbin/fdisk/mbr_bootsel.S to contain:

*** 261,286 ****

  /*
   * Get the initial time value for the timeout comparison. It is returned
!  * by int 1a in cx:dx. We do sums modulo 2^16 so it doesn't matter if
!  * the counter wraps (which it does every hour) - so we can safely
!  * ignore 'cx'.
   *
   * Loop around checking for a keypress until we have one, or timeout is
   * reached.
   */
        xorb    %ah,%ah
        int     $0x1a
        movl    %edx,%edi
  3:
        movb    $1,%ah
        int     $0x16
        jnz     4f
        xorb    %ah,%ah
        int     $0x1a
        subl    %edi,%edx
        movw_mem_ax(timeout)
!       cmpl    %eax,%edx               /* always wait for 1 tick... */
!       jbe     3b                      /* 0xffff means never timeout */
        movb_mem_al(defkey)
        jmp     default
  4:
--- 261,295 ----

This is 15 bytes smaller than the old bootsel code.
It also fixes the 'midnight' wrap problem.

Note that the above version always waits for a little while
- even when the timeout is zero.
This allows (a modified) fdisk to request 'no timeout'


>Release-Note:
>Audit-Trail:
>Unformatted: