Subject: port-i386/1762: time to enter kernel/options in boot depends on machine speed
To: None <>
From: Perry E. Metzger <>
List: netbsd-bugs
Date: 11/13/1995 21:13:56
>Number:         1762
>Category:       port-i386
>Synopsis:       time to enter kernel/options in boot depends on machine speed
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 13 21:20:01 1995
>Originator:     Perry E. Metzger
Perry Metzger
>Release:        NetBSD 1.1_ALPHA
System: NetBSD 1.1_ALPHA NetBSD 1.1_ALPHA (JEKYLL) #29: Sun Nov 12 15:13:29 EST 1995 i386

	The boot block code in port-i386 handles giving the user a few
        moments to type in a kernel name and/or kernel boot options by
        looping fast 240000 times through an input poll routine, stopping
        the looping if a character is hit and exiting and starting the
        boot process if no characer is hit. This is not a nice way to
        set a time out given that processors are becoming faster and
        faster -- within about a year, it will be impossible for users
        to hit a character fast enough without being very well
        prepared for the eventuality. It is already a bit too fast for
        comfort on a 133Mhz Pentium. This is only low priority because
        there is time before faster machines appear, but it actually
        will become Very Annoying Indeed when faster processors show up
        next year.
        The code that does this is gets (gets? what a weird gets()!)
        in /usr/src/sys/arch/i386/boot/io.c -- it calls an ischar()
        routine from bios.S in the same directory, conveniently coded
        in assembler to assure that it runs as fast as possible :-)
	Try booting a set of different speed Intel boxes.
	Simply increasing the size of the loop would be antisocial --
        many users of older machines would be adversely effected by
        this. The Right Thing is to write a little routine in
        assembler that returns a count from the the 8253/8254
        programmable interval timer and exits the loop in io.c:gets()
        not when 240000 iterations have passed but when a certain
        number of ticks in the timer chip have passed. Alternatively,
        function 0x86 of BIOS interrupt 0x15, which allows you to
        delay for a specified amount of time, could be used to
        introduce fixed 50ms delays between ischar() requests. I
        actually recommend this latter course, since the code for it
        is very simple (about fifteen lines of assembler I would
        guess) although it does mean that superhumans might notice a
        20th of a second delay between hitting the first keystroke and
        seeing an echo (who cares, but in theory its The Wrong Thing).
	None of this is hard to do at all, but as with lots of
        random trivia, I haven't actually done it.