Subject: port-i386/14748: mbr_bootsel timeouts >30 mins are treated as no timeout
To: None <>
From: None <>
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
>Originator:     David Laight
>Release:        1.5.2
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'.

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
        movb    $1,%ah
        int     $0x16
        jnz     4f
        xorb    %ah,%ah
        int     $0x1a
        subl    %edi,%edx
!       cmpl    %eax,%edx               /* always wait for 1 tick... */
!       jbe     3b                      /* 0xffff means never timeout */
        jmp     default
--- 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'